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 = "myemailwashere@website.com";
$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."; }
?>