stealthmode666 Posted December 26, 2008 Share Posted December 26, 2008 back again, this time hopefully getting somewhere, I have what I think is right, but is there a better way of writing this code to make it process every line, as at present it seems to get to a certain line, then sends the data as html/email. $body = "Rob............com:<br /><br />"; $body .= "<table align=left>"; $body .= "<tr>"; $body .= "<td width=\"200px\">Member Name</td><td width=\"200px\"> {$_POST['Member_Name']} </td><td width=\"200px\"></td><td width=\"200px\"></td>"; $body .= "</tr><tr>"; $body .= "<td>Members Contact Number</td><td> {$_POST['telephone']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Members Email Address</td><td> {$_POST['Email']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Loan Amount</td><td> {$_POST['Loan_Amount']} </td>"; $body .= "</tr> <tr>"; $body .= "<td> </td>"; //applicant details $body .= "</tr><tr>"; $body .= "<th>Main Applicant</th><td> </td><th>Joint Applicant</th>"; $body .= "</tr><tr>"; $body .= "<td>Title</td><td> {$_POST['title']} </td><td>Title</td><td> {$_POST['title1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Surname</td><td> {$_POST['surname']} </td><td>Surname</td><td> {$_POST['surname1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Forname(s)</td><td> {$_POST['forename']} </td><td>Forename(s)</td><td> {$_POST['forname1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Residential Address</td><td> {$_POST['residential']} </td><td>Residential Address</td><td> {$_POST['residential1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Town</td><td> {$_POST['town']} </td><td>Town</td><td> {$_POST['town1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>County</td><td> {$_POST['county']} </td><td>County</td><td> {$_POST['county1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Post Code</td><td> {$_POST['postcode']} </td><td>Post Code</td><td> {$_POST['post1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Lived At Address(Years)</td><td> {$_POST['years']} </td><td>Lived At Address(Years)</td><td> {$_POST['years1']} </td>"; // it will not process beyond this line and only writes Lived at Address(yea $body .= "</tr><tr>"; $body .= "<td>Lived At Address (Months)</td><td> {$_POST['months']} </td><td>Lived At Address (Months)</td><td> {$_POST['months1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Home Tel No.</td><td> {$_POST['hometelephone']} </td><td>Home Tel No.</td><td> {$_POST['hometelephone1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Mobile Tel No.</td><td> {$_POST['mobile']} </td><td>Mobile Tel No.</td><td> {$_POST['mobile1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>D.O.B</td><td> {$_POST['dateofbirth']} </td><td>D.O.B</td><td> {$_POST['dateofbirth1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Nationality</td><td> {$_POST['nationality']} </td><td>Nationality</td><td> {$_POST['nationality1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Sex</td><td> {$_POST['sex']} </td><td>Sex</td><td> {$_POST['sex1']} </td>"; $body .= "</tr><tr>"; $body .= "<td>Marital Status</td><td> {$_POST['marital']} </td><td>Marital Status</td><td> {$_POST['marital1']} </td>"; $body .= "</tr></table>"; Does anyone know what I'm doing wrong, maybe redo the code differently? I keep coming back I know, and certain suggestions have been tried, but as yet nothing works. Quote Link to comment https://forums.phpfreaks.com/topic/138435-has-my-code-got-flaws/ Share on other sites More sharing options...
sKunKbad Posted December 26, 2008 Share Posted December 26, 2008 What do you mean that it sends the data as html/email? Quote Link to comment https://forums.phpfreaks.com/topic/138435-has-my-code-got-flaws/#findComment-723825 Share on other sites More sharing options...
stealthmode666 Posted December 26, 2008 Author Share Posted December 26, 2008 the email is an html table which I have inserted the data into as opposed to a simple text email. I have added html headers to my script tell it to be displayed as html Quote Link to comment https://forums.phpfreaks.com/topic/138435-has-my-code-got-flaws/#findComment-723830 Share on other sites More sharing options...
chronister Posted December 26, 2008 Share Posted December 26, 2008 From what you have shown us, we cannot really tell what the email part should do. Based upon what you show us, I suggest coding like the following as it is much cleaner than having all those duplicated $body tags. This is more for personal preference than anything, but I have found that coding like this reduces errors greatly and no need to escape stuff. Using single quotes around strings as opposed to using double quotes will keep you from having to escape " in the html. It also "forces" you to concatenate your variables / strings thereby making the variables stand out more ensuring that you have coded properly. Getting into this type of habit will save headaches in the long run because the code is easier to read. That's my opinion anyway, for what it's worth. <?php $body = 'Rob............com:<br /><br />'. '<table align="left">'. '<tr>'. '<td width="200px">Member Name</td><td width="200px"> '.$_POST['Member_Name']. '</td><td width="200px"></td><td width="200px"></td>'. '</tr><tr>'. '<td>Members Contact Number</td><td> '.$_POST['telephone'].' </td>'. '</tr><tr>'. '<td>Members Email Address</td><td> '.$_POST['Email'].' </td>'. '</tr><tr>'. '<td>Loan Amount</td><td> '.$_POST['Loan_Amount'].'</td>'. '</tr> <tr>'. '<td> </td>'; ?> Now on to the premature evacuation (sending the email.... sorry it's late I'm tired and it was funny to me damnit) Where does it stop processing the body var? How much are you expecting it to send vs what is it actually sending. Is the cutoff point consistent, meaning does it stop reading the lines at a particular point everytime? More info please. Nate Quote Link to comment https://forums.phpfreaks.com/topic/138435-has-my-code-got-flaws/#findComment-723871 Share on other sites More sharing options...
stealthmode666 Posted January 3, 2009 Author Share Posted January 3, 2009 Chronister, Was having a Xmas break but back to the grind stone now, thanks so much for your help and input into my coding, I will redo the code and see if it makes a difference, it certainly looks a lot cleaner and easier to read. And yes, my script gets to a certain line every time then sends the data and disregards everything from the form fields beyond that Quote Link to comment https://forums.phpfreaks.com/topic/138435-has-my-code-got-flaws/#findComment-728833 Share on other sites More sharing options...
stealthmode666 Posted January 3, 2009 Author Share Posted January 3, 2009 I have redone the code. Using single quotes around strings as opposed to using double quotes will keep you from having to escape " in the html. It also "forces" you to concatenate your variables / strings thereby making the variables stand out more ensuring that you have coded properly. <?php $body = 'Robert. You have received these contact details .com:<br /><br />'. '<table align="left", border="1px">'. '<tr>'. '<td width="200px">Member Name</td><td width="200px"> '.$_POST['Member_Name']. '</td><td width="200px"></td><td width="200px"></td>'. '</tr><tr>'. '<td>Members Contact Number</td><td> '.$_POST['telephone'].'</td>'. '</tr><tr>'. '<td>Members Email Address</td><td> '.$_POST['Email'].'</td>'. '</tr><tr>'. '<td>Loan Amount</td><td> '.$_POST['Loan_Amount'].'</td>'. '</tr> <tr>'. '<td> </td>'. //applicant details '</tr><tr>'. '<th>Main Applicant</th><td> </td><th>Joint Applicant</th>'. '</tr><tr>'. '<td>Title</td><td> '.$_POST['title'].'</td><td>Title</td><td> '.$_POST['title1'].'</td>'. '</tr><tr>'. '<td>Surname</td><td> '.$_POST['surname']. '</td><td>Surname</td><td> '.$_POST['surname1']. '</td>'. '</tr><tr>'. '<td>Forname(s)</td><td> '.$_POST['forename']. '</td><td>Forename(s)</td><td> '.$_POST['forname1']. '</td>'. '</tr><tr>'. '<td>Residential Address</td><td> '.$_POST['residential']. '</td><td>Residential Address</td><td> '.$_POST['residential1']. '</td>'. '</tr><tr>'. '<td>Town</td><td> '.$_POST['town']. '</td><td>Town</td><td> '.$_POST['town1']. '</td>'. '</tr><tr>'. '<td>County</td><td> '.$_POST['county']. '</td><td>County</td><td> '.$_POST['county1']. '</td>'. '</tr><tr>'. '<td>Post Code</td><td> '.$_POST['postcode']. '</td><td>Post Code</td><td> '.$_POST['post1']. '</td>'. '</tr></table>'; ?> The script only processes the form data up to a certain line then sends that data regardless of any more lines in the processing script. Post Code AB1 2CD (same line and row in email) P (This is as far as the script gets then sends the data). I have also put in a table border just to let me see the processed data easier in the email that is sent. Quote Link to comment https://forums.phpfreaks.com/topic/138435-has-my-code-got-flaws/#findComment-728922 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.