spainsoccerfreak Posted January 29, 2009 Share Posted January 29, 2009 OK SO I got these html and php working to send info to my email got conditions if for example name is empty display a message but I want it when the press the send button if the require field is not field not to go to the next page and send me email here the php for email condition <code> //E-Mail validation if(empty($email)) echo "<br/> Please enter your email address."; else // IF USER ENTERED AN INVALID EMAIL ADDRESS if(preg_match('/.*@.*\..*/', $email) > 0) echo "<br/>Email: $email"; else echo " <br/> Email: Please enter a valid email address."; //E-Mail validation Link to comment https://forums.phpfreaks.com/topic/142982-php-form-validate-email-address/ Share on other sites More sharing options...
revraz Posted January 29, 2009 Share Posted January 29, 2009 Add the redirect under your invalid area. Link to comment https://forums.phpfreaks.com/topic/142982-php-form-validate-email-address/#findComment-749725 Share on other sites More sharing options...
milesap Posted January 29, 2009 Share Posted January 29, 2009 if (empty($_POST['email'])) { print "<br /> Please enter your email address."; } elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { print " <br /> Email: Please enter a valid email address."; } else { print "<br />Email: $_POST[email]"; } Link to comment https://forums.phpfreaks.com/topic/142982-php-form-validate-email-address/#findComment-749727 Share on other sites More sharing options...
spainsoccerfreak Posted January 29, 2009 Author Share Posted January 29, 2009 Ho DO I Add the redirect under your invalid area????? Link to comment https://forums.phpfreaks.com/topic/142982-php-form-validate-email-address/#findComment-749767 Share on other sites More sharing options...
milesap Posted January 29, 2009 Share Posted January 29, 2009 if (empty($_POST['email'])) { print "<br /> Please enter your email address."; } elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { print " <br /> Email: Please enter a valid email address."; } else { header('Location: http://www.example.com'); } Link to comment https://forums.phpfreaks.com/topic/142982-php-form-validate-email-address/#findComment-749777 Share on other sites More sharing options...
spainsoccerfreak Posted January 29, 2009 Author Share Posted January 29, 2009 Still send the email goes to the next page where is says please enter your email address I need it ti not to to the next screen if it doesnt put in the required fields Link to comment https://forums.phpfreaks.com/topic/142982-php-form-validate-email-address/#findComment-749801 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.