hans8233
02-07-2010, 08:53 PM
Hey all-
I have the following php for a form email:
<?php
$to = "myemail@gmail.com.com" ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "RSVP";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"RSVP"} = "RSVP";
$fields{"Message"} = "Message";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: myemail@gmail.com";
$subject2 = "Thank you for RSVP'ing";
$autoreply = "Thank you for RSVP'ing! We hope that you checked that you were coming. We can't wait for July 24th! Kristi & Graham";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.mysite.com/index.html" );}
else
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; }
}
}
?>
It works fine as is. (it's an RSVP for my wedding). I don't want an email to be necessary though. When I take out:
if($from == '') {print "You have not entered an email, please go back and try again";} , hitting submit on my html page just takes the browser to a blank page that is .../contact.php.
How can i fix this so email isn't required, and the page is redirected towards my index?
Thanks in advance.
I have the following php for a form email:
<?php
$to = "myemail@gmail.com.com" ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "RSVP";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"RSVP"} = "RSVP";
$fields{"Message"} = "Message";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: myemail@gmail.com";
$subject2 = "Thank you for RSVP'ing";
$autoreply = "Thank you for RSVP'ing! We hope that you checked that you were coming. We can't wait for July 24th! Kristi & Graham";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.mysite.com/index.html" );}
else
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; }
}
}
?>
It works fine as is. (it's an RSVP for my wedding). I don't want an email to be necessary though. When I take out:
if($from == '') {print "You have not entered an email, please go back and try again";} , hitting submit on my html page just takes the browser to a blank page that is .../contact.php.
How can i fix this so email isn't required, and the page is redirected towards my index?
Thanks in advance.