PDA

View Full Version : PHP form sends blank email.


Lindsay.Gelle
11-02-2010, 12:35 AM
Hi responder. I am new to PHP / HTML and I recently tried making a contact form. On the surface it looks fine, and it even sends emails, but when it does, no information from the text feilds is sent through. I don't understand why? Could anyone please take a look at my code and point out what it's missing perhaps?

I've included it below.



(THIS IS THE CODE FOR THE TABLE)
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td><strong>Contact Anya</strong></td>
</tr>
</table>
<table width="150" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="send_contact.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#1e1e1e">
<tr>
<td width="10%">Subject</td>
<td width="2%">:</td>
<td width="82%"><input name="subject" type="text" id="subject" size="25"></td>
</tr>
<tr>
<td>Details</td>
<td>:</td>
<td><textarea name="detail" cols="19" rows="4" id="detail"></textarea></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input name="name" type="text" id="name" size="25"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="customer_mail" type="text" id="customer_mail" size="25"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form></td>
</tr>
</table>



(PHP SCRIPT)
<?php
// Contact subject
$subject ="$subject";
// Details
$message="$detail";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";

// Enter your email address
$to ='lushnloud@gmail.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your inquiry information";
}
else {
echo "ERROR";
}
?>

edbr
11-02-2010, 01:15 AM
$message="$detail"; is not defined, in fact none of your variables are
example



$detail=$_POST['detail'];
$name=$_POST['name'];


add to the top of the script but you need to repeat for each passed value

Lindsay.Gelle
11-02-2010, 07:49 AM
Thank you Edbr. I'm uploading my altered PHP now. I am hopeful this is the solution :).