Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/138435-has-my-code-got-flaws/
Share on other sites

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

  • 2 weeks later...

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.