Hi. I'm extremely new to PHP, which is probably why I'm encountering some trouble here. I am trying to design my own wedding website, and so far everything is working nicely, except for the newest addition: I embedded some form HTML into one page so that I could collect guests' address information and then use a PHP script to have it emailed to me. See page here:
http://carlosandamy.us/infohome.html (and please ignore bad looking and wacky HTML and CSS design, I'm new to this!!!)
My hosting account allows for all of this, and the crazy part is that it works, sometimes. It seems to me that it works just fine when I use the "return" key on my keyboard to submit the form. I get redirected to the success page per my PHP script, and my email inbox receives the message.
But when I click the submit button, it doesn't work. I get redirected to the same success page, but no email is sent.
Here is my PHP script:
Code:
<?
// making this stuff into local values
$from = "from: me (at) hidingaddres.com";
$to = "us (at) carlosandamy.us";
$subject = "WeddingAddresses";
$Name = Trim(stripslashes($_POST['Name']));
$Street = Trim(stripslashes($_POST['Street']));
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Zip = Trim(stripslashes($_POST['Zip']));
$Email = Trim(stripslashes($_POST['Email']));
// creating email message
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Street: ";
$Body .= $Street;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "State: ";
$Body .= $State;
$Body .= "\n";
$Body .= "Zip: ";
$Body .= $Zip;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
// sending email
$success = mail($to, $subject, $Body, $from);
// success - redirecting to my home page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.carlosandamy.us\">";
}
// failure - redirecting to error version of home page
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=htt://www.carlosandamy.us/error.html\">";
}
?>
Does anyone have an explanation? Is something wrong with my PHP or with the code behind my submit button?