Log in

View Full Version : php processing script doing weird things



stealthmode666
12-20-2008, 09:50 PM
I have a serious issue here. I have a form which on submit goes to a php script to process the form fields then send the form fields to my email address as a html file.
Somehow the email is coming back to me with-out all the form fields?
It's as if the script runs, but before it gets to the end of the processing, it sends what-ever form fields it likes, as in it is missing the last form fields from my form.
I used an array then I swithced the processing to send the form data in a table with TR and TD and same problem, only part of the form fields come back to me.
Any-one ever encountered this before?

Snookerman
12-20-2008, 10:44 PM
Could you post the code you are using?

stealthmode666
12-20-2008, 11:19 PM
Here is the code so far, I have left out the fields array() which I just commented out just now in original script as I want to use a table to display the form fields data instead in the email that comes back to me.
Thanks for looking because i'm spending days going out of my mind here not understanding what is going on.


<?php
$to = ( isset ($_REQUEST['sendto']) ? $_REQUEST['sendto'] : "default 'to' email goes here" );
$from = ( isset ($_REQUEST['Email']) ? $_REQUEST['Email'] : "default 'from' email goes here" ) ;
$name = ( isset ($_REQUEST['Member_Name']) ? $_REQUEST['Member_Name'] : "Default member name goes here" ) ;
$headers = "From: $from";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$subject = "Members Data From ......";
$body = "Robert.........details..... .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>&nbsp;<tr>";
$body .= "<td>&nbsp;</td>";

//applicant details
$body .= "</tr><tr>";
$body .= "<th>Main Applicant</th><td>&nbsp;</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>";
$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>";


$headers2 = "From: me@somewhere.co.uk";
$subject2 = "Thank-you for filling in the Form ";
$autoreply = "Somebody from.. will get back to you as soon as possible, Thank-you";

if($from == '') {print "You have not entered an Email Address, please go back and try again";}
else {
if($name == '') {print "You have not entered a First Name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send){header( "Location: http://www....k/r..../thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify webmaster@me.co.uk"; }
}
}
?>

It gets to this line and if I enter a post-code in the form in both fields it posts only one post-code and ignores the script from there on in


$body .= "<td>Post Code</td><td> {$_POST['postcode']} </td><td>Post Code</td><td> {$_POST['post1']} </td>";


Tha actual form has a lot more code to go in but at this stage it fails me.

stealthmode666
12-20-2008, 11:35 PM
If its any help all i'm trying to do is have the email display two columns with the form data.
A main applicant on one side and the joint applicant on the other.
Like I say it works but only for the first 16 lines then the script seems to give-up if this makes sense!

If someone can show me how I can sort my array() into displaying two colums of data in rows this would do me until I learn more about php.
This might be an easier route to take just now.

stealthmode666
12-21-2008, 02:10 PM
Can someone show me how to use a variable instead of the $POST in my script in all the $body elements?
I believe the POST function is having an issue with the email



$body = "Robert. You have received these contact details... .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>&nbsp;<tr>";
$body .= "<td>&nbsp;</td>";
$body .= "</tr></table>";


I have about 200 fields in all, this is only a snippet so hopefully you can help me to convert the post into a variable