I have added the following contact form to my site however when I use the code it records that an email has been sent but no email is received at the respective email address.
Is there anything I need to set up email system to work other than just the code on the page?
<table width="400" border="0" cellpadding="0" cellspacing="1" bgcolor="#EDEDED" border="1">
<tr>
<td><form name="form1" method="post" action="contactsend.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td>Subject:</td>
<td width="82%"><input name="subject" type="text" id="subject" size="50"></td>
</tr>
<tr>
<td>Message:</td>
<td><textarea name="detail" cols="50" rows="10" id="detail"></textarea></td>
</tr>
<tr>
<td>Name:</td>
<td><input name="name" type="text" id="name" size="50"></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="customer_mail" type="text" id="customer_mail" size="50"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?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 ='*****@****.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 "Thank You for Contacting Us. We will endevour to reply as soon as possible.";
}
else {
echo "ERROR";
}
?>
There is nowhere in your PHP where you extract the values passed from the form in the $_POST array into the variables that the PHP script is using. None of the vaiables your PHP script is using are ever given vallues to use in the subsequent processing.
Note also that you shouldn’t just directly assign the values across - you should validate the content of $_POST[‘customer_email’] using the appropriate validation filter to ensure that it is a valid email address format before moving the value to $customer_email (and similarly for all the other fields).
Apart from the missing PHP in the example you posted above, the HTML itself is dreadful … using a table where it doesn’t belong, and using no labels that can be associated with the form inputs. I highly recommend you delete that code and never think of using it again!
Have you changed your HTML? If you have something like $_POST[‘Name’], the work “Name” must correspond to the name=“” attribute in your form code. You had name=“name”, which won’t match because of the capital/lower case. My advice is never to use capitals in code. It leads to lots of unnecessary errors.
And you won’t pick up things like name=“customer_mail”.
Also, make sure $EmailFrom corresponds to an email address.
I copied it like for like. I have gone through it all and changed it to lower case.
Not sure what you mean by this "Also, make sure $EmailFrom corresponds to an email address. " Do I need to put an email address in there? I thought was just a title.
Maybe just repost all the code you have—HTML and PHP. It doesn’t look like you’ve got a complete setup there. But yes, the $EmailFrom is expecting an email address.
hi i have a similar issue ( but different in as my php form throws the error up and no email delivered) can i post it here or should i start a new thread?