100 Web Space
http://forum.100webspace.com/

please help wth simple PHP mail form
http://forum.100webspace.com/viewtopic.php?f=5&t=5996
Page 1 of 1

Author:  guatetaliana [ Mon Feb 19, 2007 11:35 pm ]
Post subject:  please help wth simple PHP mail form

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?

Author:  scorpian8867 [ Tue Feb 20, 2007 1:40 am ]
Post subject: 

I had this same problem. In the email header, the "from" area needs to be an email account that you got with your 100WS hosting package. I don't think you get this with a free package, if that's what you're using. Otherwise, you're good. :)

Author:  guatetaliana [ Tue Feb 20, 2007 1:55 am ]
Post subject: 

Thanks, scorpian. I am on a paid hosting account, and the address in the from field is one of my accounts.

This is driving me nuts. It definitely works when I hit the "return" key after filling out the form. Just not when I push the button.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/