TruSake Posted March 19, 2013 Share Posted March 19, 2013 Hi, I got an email contact form page on my website, with the following php code: <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $formcontent=" From: $name \n Message: $message"; $recipient = "elvis@presley.com"; $subject = "Web Mail"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); $url = 'www.somesite.com'; echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> 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. Can anyone tell me what the code would be to have all fields required to be filled? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/275838-php-email-question/ Share on other sites More sharing options...
NiTx Posted March 19, 2013 Share Posted March 19, 2013 You would need to add some form vaildation. Won't take you long to learn it. http://lmgtfy.com/?q=php+form+validation You can find video tutorials on form validation through youtube too. Good luck Quote Link to comment https://forums.phpfreaks.com/topic/275838-php-email-question/#findComment-1419468 Share on other sites More sharing options...
cyberRobot Posted March 19, 2013 Share Posted March 19, 2013 If you haven't done so already, you'll also want to look into e-mail injections: https://www.google.com/search?q=php+email+injection Quote Link to comment https://forums.phpfreaks.com/topic/275838-php-email-question/#findComment-1419550 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.