Jump to content

Need help with email form


ccarcia3

Recommended Posts

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."; }
?>

Link to comment
https://forums.phpfreaks.com/topic/245925-need-help-with-email-form/
Share on other sites

<?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."; 
//
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.