bob_the _builder Posted March 4, 2008 Share Posted March 4, 2008 Hi, I now have the following but .. all variables formated as $_POST['lastname'][$i] dont hold any data, altho $total still holds the correct data? case 'showtrans': echo '<form name="trans" method="post" action="'.$_SERVER['PHP_SELF'].'?action=processtrans"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">'; $sql = mysql_query("SELECT * FROM cctrans ORDER BY firstname ASC"); while($row = mysql_fetch_array($sql)) { foreach($row as $key=>$value){ $$key = ValidateOutput($value); } echo '<tr> <td width="40%">'.$firstname.' '.$lastname.' - Total = <b>$'.$total.'</b></td> <td width="60%">Total including freight + 4% <input name="total[]" type="text" size="10"></td> </tr>'; } echo '<tr> <td colspan="2" align="right"> <input type="hidden" name="method[]" value="'.$method.'"> <input type="hidden" name="firstname[]" value="'.$firstname.'"> <input type="hidden" name="lastname[]" value="'.$lastname.'"> <input type="hidden" name="emailaddress[]" value="'.$emailaddress.'"> <input type="hidden" name="transid[]" value="'.$transid.'"> <input type="submit" name="Submit" value="Submit"> </td> </tr> </table> </form>'; break; case 'processtrans': echo '<b>Successfully emailed out the following totals including freight to:</b><br /><br />'; $sql = mysql_query("SELECT companyname, companyemail FROM company WHERE companyid = 1"); while ($row = mysql_fetch_array($sql)) { $companyname = $row['companyname']; $companyemail = $row['companyemail']; } foreach(array_filter($_POST['total']) as $i=>$total){ // Set payment choice to email client if ($_POST['method'][i] == 'Direct Credit') { $payment = 'Please deposit the sum of: <b>$'.$total.'</b>nzd, incl gst into the following Bank Account: <br /><br /> $companyname <br /><br /> $bank <br /><br /> <b>Acc No:</b> $account'; } if ($_POST['method'][i] == 'Cheque') { $payment = 'Please post a cheque to the sum of: <strong>$'.$total.'</strong>nzd incl gst crossed and made payable to: <br /><br /> $companyname <br /><br /> $address'; } if ($_POST['method'][i] == "Paypal") { $payment = 'Please <a href="http://www.test.com/paypal.php?order=order&firstname='.$_POST['firstname'][i].'&lastname='.$_POST['lastname'][i].'&email='.$_POST['emailaddress'][i].'&total='.$total.'">CLICK HERE</a> to complete your order'; } // Mail Client $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: $companyname <$companyemail>\r\n"; $headers .= "Reply-To: $companyemail <$companyemail>\r\n"; $to = "".$_POST['firstname'][$i]." ".$_POST['lastname'][$i]." <".$_POST['emailaddress'][$i].">"; $subject = "$companyname order confirmation"; $message = 'Hi '.$_POST['firstname'][$i].', <br /><br /> Your new total including freight is: <b>$'.$total.'</b> <br /><br /> '.$payment.' <br /><br /> Regards <br /><br /> The Team @ '.$companyname.''; mail($to, $subject, $message, $headers); echo ''.$_POST['firstname'][$i].' '.$_POST['lastname'][$i].' - '.$_POST['emailaddress'][$i].' '.$total.'<br />'; } Thanks Quote Link to comment Share on other sites More sharing options...
rbrown Posted March 4, 2008 Share Posted March 4, 2008 I'm not seeing where you are setting the $_POST['firstname'][$i] in an array. try dropping the[$i] after it. Also make sure you are passing the data from the form to the script. Do an echo of the data as a test. Quote Link to comment Share on other sites More sharing options...
Chris92 Posted March 4, 2008 Share Posted March 4, 2008 I noticed you had if ($_POST['method'][i] == "Paypal") { $payment = 'Please <a href="http://www.test.com/paypal.php?order=order&firstname='.$_POST['firstname'][i].'&lastname='.$_POST['lastname'][i].'&email='.$_POST['emailaddress'][i].'&total='.$total.'">CLICK HERE</a> to complete your order'; } you might want to put a $'s infront of your i's, For the rest I can't see why it shouldn't be showing the posted data. To be honest i don;t think you need to put you posted data into an extra array because it is only being shown once unless you validatouput function is doing something Also what is it that isn;t giving you the data? is it the email or the page? Quote Link to comment Share on other sites More sharing options...
bob_the _builder Posted March 4, 2008 Author Share Posted March 4, 2008 Hi, I added the $ to the i, no difference. if I echo the following within the processtrans case the only result I get back is the $total variable: echo ''.$_POST['firstname'][$i].' '.$_POST['lastname'][$i].' - '.$_POST['emailaddress'][$i].' '.$total.'<br />'; The from could hold 3 records, but I only submit totals for 2 of the records and post the form the result I get from the above echo is: - 1.00 - 3.00 So each variable as $_POST['firstname'][$i] etc are empty. I need to loop thru each record in the form and email the data from each record to the matching email address. ? Thanks Quote Link to comment Share on other sites More sharing options...
bob_the _builder Posted March 5, 2008 Author Share Posted March 5, 2008 any idea? Thanks 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.