March 18th, 2013, 11:07 PM
PHP email question
I got an email contact form page on my website, with the following php code:
Now, it works just fine when sending, but my situation is that apparently people can just press the Send button even if they don't fill everything out.
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent=" From: $name \n Message: $message";
$recipient = "firstname.lastname@example.org";
$subject = "Web Mail";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
$url = 'URL ADDRESS!/page_More';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
Can anyone tell me what the code would be to have all fields required to be filled?
March 18th, 2013, 11:14 PM
Test your variables to see that they contain reasonable values. If they don't, return an error, or return to the previous page with an error message, or ..... whatever you want.
March 18th, 2013, 11:47 PM
THIS LINK should offer you some direction.
Last edited by DonR; March 18th, 2013 at 11:57 PM.