I have been messing with my php code for a week now and I can’t figure out what is wrong with it. I am trying to have my contact form work correctly, so I can receive emails from my viewers on my site. I have my contact.html and I have a php form to go with it. The contact form in html is actioned to my mailer.php. When I do my test on it, it goes to a blank page after I submit it. If anyone can help me that would be great. I am new to the php coding, but I am wanting to learn it. I will probably need some guidance through this.
<?php $sendMessage = false; if (isset ($_REQUEST['message']) && isset($_REQUEST['email']) && isset($_REQUEST['name'])) { $email = $_REQUEST['email']; $name = $_REQUEST['name']; $subject = $_REQUEST['subject']; $message = $_REQUEST['message']; if (strlen($message) > 0 && strlen($email) > 0 && strlen($subject) > 0 && strlen($name) > 0) { $sendMessage = true;} } if (isset ($_REQUEST['posted']) && (!$sendMessage)) { echo "Please fill in all the values";} if ($sendMessage) { //[email protected] $to= "[email protected]"; $subject= "Website Feedback."; $headers= "Mime Version: 1.0". "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers .= "From: $email\r\n"; // setup the from field for e-mail $headers .= "Content-type: text/html\r\n"; // setup e-mail format $success = mail($to, $subject, $message, $headers); if ($success) // if successful display the message & success message { echo "You sent the following:$message
"; echo "
Form submitted successfully.
"; } else // If not successful let the user know { echo "An error occurred when trying to send the e-mail."; } } ?>