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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.