March 19th, 2013, 12:07 AM
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 = "email@example.com";
$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 19th, 2013, 12:14 AM
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 19th, 2013, 12:47 AM
THIS LINK should offer you some direction.
Last edited by DonR; March 19th, 2013 at 12:57 AM.