oldguard Posted August 12, 2004 Share Posted August 12, 2004 Can someone tell Dummy here why the script below won't work?? Help!!! Thank you OG <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>Intertask - Step 1<?=$_POST;?></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"><!--span.error { font-size: 9px; font-weight: bolder; color: #FF0000;}body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}a:link, a:visited { text-decoration:none; font-weight:bold; color:#304A8E;}a:hover{ text-decoration:underlined;}body, td, p, li, ul, ol, div, .default{ font-family: verdana,helvetica,arial; font-size: 11px; color:#000000;}--></style></head><body><img src="images/hd_intertask.gif" width="156" height="42" hspace="7" vspace="8"><?phpfunction print_step1($error){ ?><form name="form1" method="post" action=""> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr align="center"> <td colspan="7"> </td> </tr> <tr align="center"> <td colspan="7"><strong>To find out how much Conexa e-Procurement can save your business –</strong><br> <strong> fill out the form below and click "Submit"</strong></td> </tr> <tr> <td height="20" colspan="7"> </td> </tr> <tr align="center"> <td height="30" colspan="7">Enter your information below:</td> </tr> <tr> <td height="20" colspan="7"> </td> </tr> <tr> <td width="50%" height="20" nowrap><img src="images/px_trans.gif" width="100" height="1"></td> <td nowrap>First Name</td> <td > </td> <td width="30%"><input name="first_name" type="text" id="first_name" style="width:100%" value="<?=$_POST[first_name];?>"> </td> <td nowrap> </td> <td nowrap> <? if ($error[first_name]){?> <span class="error" > << </span> <?}?> </td> <td width="50%" nowrap><img src="images/px_trans.gif" width="100" height="1"></td> </tr> <tr> <td width="50%" nowrap> </td> <td nowrap>Surname</td> <td> </td> <td width="100%"><input name="sur_name" type="text" id="sur_name4" value="<?=$_POST[sur_name];?>" style="width:100%"></td> <td nowrap> </td> <td nowrap> <? if ($error[sur_name]){?> <span class="error" > << </span> <?}?> </td> <td width="50%" nowrap> </td> </tr> <tr> <td width="50%" nowrap> </td> <td nowrap>Company Name</td> <td> </td> <td width="100%"><input name="company_name" type="text" id="company_name" value="<?=$_POST[company_name];?>" style="width:100%"> </td> <td nowrap> </td> <td nowrap> <? if ($error[company_name]){?> <span class="error" > << </span> <?}?> </td> <td width="50%" nowrap> </td> </tr> <tr> <td width="50%" nowrap> </td> <td nowrap>Position</td> <td> </td> <td width="100%"><input name="position" type="text" id="position" value="<?=$_POST[position];?>" style="width:100%"> </td> <td nowrap> </td> <td nowrap> <? if ($error[position]){?> <span class="error" > << </span> <?}?> </td> <td width="50%" nowrap> </td> </tr> <tr> <td width="50%"> </td> <td>Email</td> <td> </td> <td width="100%"><input name="email" type="text" id="email" value="<?=$_POST;?>" style="width:100%"> </td> <td nowrap> </td> <td nowrap> <? if ($error){?> <span class="error" > << </span> <?}?> </td> <td width="50%" nowrap> </td> </tr> <tr align="center"> <td colspan="7"> </td> </tr> <tr align="center"> <td colspan="7"> (all fields are mandatory)</td> </tr> <tr align="center"> <td colspan="7"> </td> </tr> <tr align="center"> <td colspan="7"><input name="post" type="hidden" id="post" value="1"> <input type="submit" name="Submit" value="Submit"> </td> </tr> <tr align="center"> <td colspan="7"> </td> </tr> <tr align="center"> <td colspan="7"> <a href="#" onclick="javascript:window.opener.location='privacy.html'">Privacy Policy</a></td> </tr> <tr align="center"> <td colspan="7"> </td> </tr> </table><p> </p></form><?}?><?phpfunction print_step2($error){?><script>function sum_all(){ var pos1=round(document.forms[0].a.value);var pos2=round(document.forms[0].b.value);document.forms[0].a.value=numberFormat(document.forms[0].a.value);document.forms[0].b.value=numberFormat(document.forms[0].b.value); document.forms[0].c.value=numberFormat(pos1+pos2); }function round(number,decPlace) { decPlace = (!decPlace ? 2 : decPlace); return Math.round(number * Math.pow(10,decPlace)) / Math.pow(10,decPlace); }function numberFormat(amount) { var rawNumStr = round(amount) + ''; rawNumStr = (rawNumStr.charAt(0) == '.' ? '0' + rawNumStr : rawNumStr); if (rawNumStr.charAt(rawNumStr.length - 3) == '.') { return rawNumStr } else if (rawNumStr.charAt(rawNumStr.length - 2) == '.') { return rawNumStr + ''; } else { return rawNumStr + ''; } } function numberFormat_Integer(amount) { var rawNumStr = round(amount) + ''; rawNumStr = (rawNumStr.charAt(0) == '.' ? '0' + rawNumStr : rawNumStr); if (rawNumStr.charAt(rawNumStr.length - 0) == '.') { return rawNumStr } } function isNumber(inputVal) {oneDecimal = falseinputStr = inputVal.toString()for (var i = 0; i < inputStr.length; i++) {var oneChar = inputStr.charAt(i)if (i == inputStr.length-1 && oneChar == ".") {return false}if (i == 0 && oneChar == "-") {continue}if (oneChar == "." && !oneDecimal) {oneDecimal = truecontinue}if (oneChar < "0" || oneChar > "9") {return false}}return true} function isNumber_integer(inputVal) {oneDecimal = trueinputStr = inputVal.toString()for (var i = 0; i < inputStr.length; i++) {var oneChar = inputStr.charAt(i)if (i == inputStr.length-1 && oneChar == ".") {return false}if (i == 0 && oneChar == "-") {continue}if (oneChar == "." && !oneDecimal) {oneDecimal = truecontinue}if (oneChar < "0" || oneChar > "9") {return false}}return true} </script><form action="" method="post" name="form2"> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="5"> <strong><?=$_POST[first_name]?></strong> <input name="company_name" type="hidden" value="<?=$_POST[company_name]?>"> <input name="first_name" type="hidden" value="<?=$_POST[first_name]?>"> <input name="email" type="hidden" id="email3" value="<?=$_POST;?>" > <input name="position" type="hidden" id="position" value="<?=$_POST[position];?>" > <input name="sur_name" type="hidden" id="sur_name" value="<?=$_POST[sur_name];?>" > </td> </tr> <tr> <td colspan="5"> </td> </tr> <tr> <td colspan="5">Thank you for your interest in Conexa e-Procurement. Please answer the questions below and then click Calculate.</td> </tr> <tr> <td colspan="5"> </td> </tr> <tr> <td colspan="5">Your results will appear.</td> </tr> <tr> <td colspan="5"> </td> </tr> <tr> <td nowrap>1. Please enter the Annual MRO Expenses for <?=$_POST[company_name]?> :</td> <td align="center" nowrap>$</td> <td nowrap> <input name="a" type="text" id="PROD2_1" value="<? if ($_POST[a]){echo $_POST[a];}else{echo '0';}?>" size="15" onblur="javascript: if (isNumber(document.forms[0].a.value)){ sum_all(); } else{ alert('Inposable value'); document.forms[0].a.value='0'; sum_all(); document.forms[0].a.focus(); }" /> </td> <td nowrap> <? if ($error[a]){?> <span class="error" > << </span> <?}?> </td> <td nowrap> </td> </tr> <tr> <td colspan="5">• MRO (Maintenance / Repairs / Operations) expenses</td> </tr> <tr> <td colspan="5"> </td> </tr> <tr> <td>* Please enter ofther Expenses from Ordinary Activities for <?=$_POST[company_name]?> :</td> <td align="center">$</td> <td> <input name="b" type="text" id="PROD2_1" value="<? if ($_POST){echo $_POST;}else{echo '0';}?>" size="15" onblur="javascript: if (isNumber(document.forms[0].b.value)){ sum_all(); } else{ alert('Inposable value'); document.forms[0].b.value='0'; sum_all(); document.forms[0].b.focus(); }" /></td> <td> <? if ($error){?> <span class="error" > << </span> <?}?> </td> <td> </td> </tr> <tr> <td colspan="5"> • Food & Beverage expenses<br> • Services purchased<br> • Printing & Stationary expenses </td> </tr> <tr> <td align="right">Total Expenses</td> <td align="center">$</td> <td><input name="c" type="text" id="c" value="<? if ($_POST[c]){echo $_POST[c];}else{echo '0';}?>" readonly size="15"> </td> <td> </td> <td> </td> </tr> <tr> <td align="right"> </td> <td align="center"> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>* How many Purchase Orders does <?=$_POST[company_name]?> issue per week? (estimate is fine):</td> <td align="center"> </td> <td> <input name="d" type="text" value="<? if ($_POST[d]){echo $_POST[d];}else{echo '0';}?>" size="15" onblur="javascript: if (isNumber_integer(document.forms[0].d.value)){ } else{ alert('Inposable value'); document.forms[0].d.value='0'; document.forms[0].d.focus(); }" /></td> <td> <? if ($error[d]){?> <span class="error" > << </span> <?}?> </td> <td> </td> </tr> <tr> <td>* How many staff process these Purchase Orders (PO’s)?</td> <td align="center"> </td> <td><input name="e" type="text" value="<? if ($_POST[e]){echo $_POST[e];}else{echo '0';}?>" size="15" onblur="javascript: if (isNumber_integer(document.forms[0].e.value)){ } else{ alert('Inposable value'); document.forms[0].e.value='0'; document.forms[0].e.focus(); }" /></td> <td> <? if ($error[e]){?> <span class="error" > << </span> <?}?> </td> <td> </td> </tr> <tr> <td>* What is the Average Hourly Wage per staff member who process the PO’s above:</td> <td align="center">$</td> <td><input name="f" type="text" value="<? if ($_POST[f]){echo $_POST[f];}else{echo '0';}?>" size="15" onblur="javascript: if (isNumber(document.forms[0].f.value)){ document.forms[0].f.value=numberFormat(document.forms[0].f.value); } else{ alert('Inposable value'); document.forms[0].f.value='0'; document.forms[0].f.focus(); }" /></td> <td valign="middle"> <?if ($error[f]){?> <span class="error" > << </span> <?}?> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr align="center"> <td colspan="5">(All items are mandatory)</td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr align="center"> <td colspan="5"><input name="post" type="hidden" id="post" value="2"> <input type="submit" name="Submit2" value="Calculate your Savings"></td> </tr> <tr> <td colspan="5"> </td> </tr> </table></form><?}?><?phpfunction print_step3($error){$arr=calculate_o($_POST);?><form action="cal_email.php" method="post" name="form3"> <input name="company_name" type="hidden" value="<?=$_POST[company_name]?>"> <input name="first_name" type="hidden" value="<?=$_POST[first_name]?>"> <input name="email" type="hidden" id="email3" value="<?=$_POST;?>" > <input name="position" type="hidden" id="position" value="<?=$_POST[position];?>" > <input name="sur_name" type="hidden" id="sur_name" value="<?=$_POST[sur_name];?>" > <input name="a" type="hidden" value="<?=$_POST[a];?>"> <input name="b" type="hidden" value="<?=$_POST;?>"> <input name="c" type="hidden" value="<?=$_POST[c];?>" > <input name="d" type="hidden" value="<?=$_POST[d];?>"> <input name="f" type="hidden" value="<?=$_POST[f];?>" > <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr align="center"> <th colspan="5">Results for <?=$_POST[company_name]?></th> </tr> <tr> <td colspan="5"> </td> </tr> <tr align="center"> <td colspan="5">Based on your entries, here is what your company could save by<br> using Conexa – our web based e-Procurement platform.</td> </tr> <tr> <td colspan="5"> </td> </tr> <tr> <td width="4%" height="177"> </td> <td colspan="3"> <table width="95%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr bgcolor="efefef"> <td><strong>3rd Party Research Statistics</strong></td> <td><strong>Savings for <nobr><?=$_POST[company_name]?></nobr></strong></td> </tr> <tr> <td align="left">Off Contract Purchasing results in an average 20% overpayment (Source: (IBM) </td> <td align="right" valign="middle">$ <?=price(($_POST[a]+$_POST)*.10)?> <input name="g" type="hidden" id="g" value="<?=price(($_POST[a]+$_POST)*.10)?>"></td> </tr> <tr> <td align="left">Commonly purchased items (MRO) purchasing costs can be reduced by 5 to 15% using e-Procurement (Source: AMR Research)</td> <td align="right" valign="middle">$ <?=price((($_POST[a])*.15))?> <input name="h" type="hidden" id="h" value="<?=price((($_POST[a])*.15))?>"></td> </tr> <tr> <td align="left">4 – 6% reduced product costs due to pricing transparency (Source: Ernst & Young) </td> <td align="right" valign="middle">$ <?=price((($_POST[a]+$_POST)*.06))?> <input name="j" type="hidden" id="j" value="<?=price((($_POST[a]+$_POST)*.06))?>"></td> </tr> <tr> <td align="left">Cost of Processing PO’s today for <?=$_POST[company_name]?> month</td> <td align="right" valign="middle">$ <?=price($arr[Gross_PO_Costs])?> <input name="j2" type="hidden" id="j3" value="<?=price($arr[Gross_PO_Costs])?>"></td> </tr> <tr> <td align="left">Cost of Processing PO’s using Conexa</td> <td align="right" valign="middle">$ <?=price($arr[NEW_Gross_PO_Costs])?> <input name="j3" type="hidden" id="j4" value="<?=price($arr[NEW_Gross_PO_Costs])?>"></td> </tr> <tr> <td align="left">Savings per Month</td> <td align="right" valign="middle">$ <?=price($arr[total])?> <input name="j4" type="hidden" id="j5" value="<?=price($arr[total])?>"></td> </tr> <tr> <td align="center"> </td> <td align="center"> </td> </tr> <tr> <td align="right">Total Savings for <?=$_POST[company_name]?> per year: </td> <td align="right" valign="middle">$<?= price(calculate_all($_POST))?> <input name="h42" type="hidden" id="h422" value="<?= price(calculate_all($_POST))?> "> </td> </tr></table> </td> <td width="4%"> </td> </tr> <tr> <td> </td> <td colspan="3" align="center"> <span style="font-size:7px;"> </span><br> How much does Conexa cost to use? Send me an email with a quote for using Conexa.<br> <span style="font-size:7px;"> </span><br> <input name="submit" type="submit" value="Send email"> </td> <td> </td> </tr> </table></form><?}function calculate_o($arr_){$arr=Array();$k= (($arr_[d]*20/60)+($arr_[e]*20/60))*$arr_[f];$l=$k*52/12;$m=(($arr_[d]*2/60)+($arr_[e]*2/60))*$arr_[f];$n=($m*52/12);$o=$l-$n;$arr[Gross_PO_Costs]=$l;$arr[NEW_Gross_PO_Costs]=$n;$arr[total]=$l-$n;return $arr;}function calculate_all($arr){$o=Array();$o=calculate_o($_POST);$g=($_POST[a]+$_POST)*.10;$h=($_POST[a])*.15;$j=($_POST[a]+$_POST)*.06;$z= ($o[total]*12)+$g+$j+$h;return $z;}function validEmail($email) { if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $email)){ return TRUE; } else { return FALSE; } }function price($value) {// -----------------------------------------------------------------------------------// Description: Converts an integer/double etc into a currency, adding commas and// trailing zeros.// $value: The currency value. $value = round($value, 2); if(strpos($value, ".")) { $pounds = substr($value, 0, strpos($value, ".")); $pence = substr($value, strpos($value, ".")); for($x = 0; $x < 3 - strlen($pence); $x++) $pence .= "0"; } else { $pounds = $value; $pence = ".00"; } $size = strlen($pounds); $count = 0; $ret = ""; for($x = $size - 1; $x >= 0; $x--) { $ret = substr($pounds, $x, 1) . $ret; $count++; if($count == 3 && $x != 0) { $ret = ",$ret" ; $count=0; } } return($ret);}?><?switch ($_POST){case "1": $are_error=0; if (trim(empty($_POST[first_name]))){ $are_error=1; $error[first_name]=1; } if (trim(empty($_POST[sur_name]))){ $are_error=1; $error[sur_name]=1; } if (trim(empty($_POST[company_name]))){ $are_error=1; $error[company_name]=1; } if (trim(empty($_POST[position]))){ $are_error=1; $error[position]=1; } if (!validEmail($_POST)){ $are_error=1; $error=1; } if ($are_error==1){ print_step1($error); } else { print_step2(''); }break;case "2":$are_error=0; if (trim(empty($_POST[a])) || !(float)($_POST[a])){ $are_error=1; $error[a]=1; } if (trim(empty($_POST)) || !(float)($_POST)){ $are_error=1; $error=1; } if (trim(empty($_POST[d])) || !(float)($_POST[d])){ $are_error=1; $error[d]=1; } if (trim(empty($_POST[e])) || !(float)($_POST[e])){ $are_error=1; $error[e]=1; } if (trim(empty($_POST[f])) || !(float)($_POST[f])){ $are_error=1; $error[f]=1; } if ($are_error==1){ print_step2($error); } else { print_step3(''); }break;default : print_step1(''); }?></body></html> Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 13, 2004 Share Posted August 13, 2004 Can someone tell Dummy here why the script below won't work?? I doubt it, because it's just about unreadable and nobody's going to take the time to figure out where one line ends and the next begins. It would help if you edited your post so that each line of your code was on a separate line, and you wrapped the code with the 'CODE' tags available here. Quote Link to comment Share on other sites More sharing options...
Websitenoobie Posted August 13, 2004 Share Posted August 13, 2004 heh or a place to DL the file... forums cant handle the length Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.