ccarcia3 Posted August 29, 2011 Share Posted August 29, 2011 To PHPBuilder Forumgoers, My PHP email form is not sending to the address I specified, and I think it's because I added in an if-else statement to check for input of a valid email address. I've put the HTML and PHP scripts online and filled the live form out with several valid email addresses, with no success. I tried changing the recipient's email, too, with no success. Am I missing a glaring error in my code, or maybe things are just not in the right order? Any help would be SUPER appreciated. Thank you so much. The code (in external PHP file "order.php") : <?php $to = "[email protected]"; $subject = "Custom Order Message"; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $from = $_REQUEST['name']; $budget = $_REQUEST['budget']; $colors[] = $_REQUEST['colors[]']; $headers = "From: $email"; $sent = mail($to, $from, $subject, $message, $budget, $headers) ; if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*". "@([a-z0-9]+([\.-][a-z0-9]+))*$",$email)) { header( 'Location: order/invalidemail.html' ) ; }else{ header( 'Location: order/messagesent.html' ) ; } if($sent) {print "Your custom order query was sent successfully."; } else {print "An error occured while sending your custom order query. Please try again."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/245925-need-help-with-email-form/ Share on other sites More sharing options...
meltingpoint Posted August 29, 2011 Share Posted August 29, 2011 <?php $to = "[email protected]"; $subject = "Custom Order Message"; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $from = $_REQUEST['name']; $budget = $_REQUEST['budget']; $colors[] = $_REQUEST['colors']; $headers = "From: $email"; // if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*". "@([a-z0-9]+([\.-][a-z0-9]+))*$",$email)) { header( "Location: order/invalidemail.html" ) ;//-------re-direct if invalid exit;//----------stops the script here so it will not send if invalid } //--------If it was valid- we continue on and send the mail and //--------echo out a message that the order was sent successfully mail($to, $from, $subject, $message, $budget, $headers) ; // echo "Your custom order query was sent successfully."; // ?> Quote Link to comment https://forums.phpfreaks.com/topic/245925-need-help-with-email-form/#findComment-1262992 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.