I need some help with a php script. I have a small website and I want to have a Registration Form that is send to my Email address. My Form is going to be a simple HTML page asking the user for name, Email and comment.
The form action will send it to my PHP form. Once error check is completed, it will be send the form to my Email address. I have read many post looked at a lot of codes and I still can’t get it to work. Once I fill out the form and submit it, the php shows that it has successfully send but I never get an Email.
Do I need to do something special on my server side to get the Form to work properly? I checked with my server host to see if php is accepted and working. They said yes but could not help me in figuring out why it is not working. I hope someone here can help me.
I included my php code here:
- Code: Select all
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
echo "error; you need to submit the form!";
echo "Name and email are mandatory!";
if (!filter_var($Email, FILTER_VALIDATE_EMAIL)) //If Email is not correct return error message
echo "<p>You entred an incorect Email (email@example.com)!</p>\n";
$email_from = 'firstname.lastname@example.org';
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.\n".
"Here is the message:\n $message".
$to = "email@example.com";
$headers = "From: $email_from \r\n";
$headers = "Reply-To: $email \r\n";
//Send the email!
//done. redirect to thank-you page.