tags:

views:

72

answers:

2

Could anyone tell me if there is something wrong with the code or a better way to modify it? for some reason when i hit submit on my contact form it displays the "error.html" page but i still get an email sent to my account.

$EmailTo = "[email protected]";
$Subject = "Contact Submission";

$Name = Trim(stripslashes($_POST['name'])); 
$Email = Trim(stripslashes($_POST['email'])); 
$Budget = Trim(stripslashes($_POST['budget'])); 
$Message = Trim(stripslashes($_POST['message']));

// prepare email body text
$Body = 'Contact Submission'."\n";
$Body .= 'Name:     '   .$Name."\n";
$Body .= 'Email:      '   .$Email."\n";
$Body .= 'Budget:      '   .$Budget."\n";
$Body .= 'Message:     '   .$Message."\n";


// send email 
$success_email = mail($EmailTo, $Subject, $Body, "From: <$Email>");

// redirect to success page
// CHANGE THE URL BELOW TO YOUR "THANK YOU" PAGE
    if ($success){
     header ('location:thankyou.html');
    } 
    else{
    header ('location:error.html');
    }
+7  A: 

Change

if ($success){

to

if ($success_email){

$success doesn't exist...

Jefe
Please accept this answer Blaze (if you ever come back to SO)
alex
A: 
 $EmailTo = "[email protected]";
$Subject = "Contact Submission";

$Name = Trim(stripslashes($_POST['name'])); 
$Email = Trim(stripslashes($_POST['email'])); 
$Budget = Trim(stripslashes($_POST['budget'])); 
$Message = Trim(stripslashes($_POST['message']));

// prepare email body text
$Body = 'Contact Submission'."\n";
$Body .= 'Name:            '   .$Name."\n";
$Body .= 'Email:           '   .$Email."\n";
$Body .= 'Budget:          '   .$Budget."\n";
$Body .= 'Message:     '   .$Message."\n";


// send email 
$success_email = mail($EmailTo, $Subject, $Body, "From: <$Email>");

// redirect to success page
// CHANGE THE URL BELOW TO YOUR "THANK YOU" PAGE
    if ($success_email){
     header ('location:thankyou.html');
    } 
    else{
    header ('location:error.html');
    }
Srirangan