Jump to content

Email Form


lisacleverley

Recommended Posts

Hi all,

 

I'm trying to add an email for for a friend on her website but can't understand why it's not working. Here is the page of the form: www.blissphoto.net/Connect.html and the code for the form below...

 

<?php

$email_address = "[email protected]";
$subject = "Contact from Website"; 


$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$date = $_POST['date'];
$referral = $_POST['referral'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comments = $_POST['comments'];

$message ="Contact Name:".$name."\n\nAddress:".$address."\n\nCity:".$city."\n\nState:".$state."\n\nZip:".$zip."\n\nDate:".$date."\n\nReferral:".$referral."\n\n;Phone:".$phone."\n\nE-mail:".$email."\n\nComments:".$comments;

mail($toname."<".$email_address.">",$subject,$message,"From: ".$name."<".$email.">");

//Redirects to thank-you.html 
    header("Location: thank-you.html")

?>

 

Any advise appreciated.

 

Thanks,

Lisa

Link to comment
https://forums.phpfreaks.com/topic/56766-email-form/
Share on other sites

If you want php to post the form it has to be a .php page on a PHP enabled server other wise php wont work.

 

Also $name = $_POST['name']; isn't necessary you can just use $_POST['name']; in the mail function.

Well then I'm confused because on my own website I use htm pages with php email forms that work perfectly fine. See www.lisacleverley.com/contact.htm  ???

 

I just ran your script and it sent OK

Yes it appears to forward onto the Thank you page but nothing ever comes through in the email. I have it set on the server to send to my email until I know it's fully working then will transfer to friends email.
Link to comment
https://forums.phpfreaks.com/topic/56766-email-form/#findComment-280365
Share on other sites

right, your form action is to send.php (on your site) so thats cool then.

 

If the page is redirecting then the script is exec. fine and I ran your script and it does send.

 

Try simplifying the mail function to it's most basic form eg

 

mail('mail@example', 'My Subject', 'Test');

 

and comment out the rest and see if it works. if it doesn't then the problem is with PHP or the ini set up

 

check the obvious stuff too like the address. Try another address to make sure the issue isn't with your friends email account. Send to her account from your account too. Just try to work out where its failing by testing all the different parts to running the script and getting the mail.

Link to comment
https://forums.phpfreaks.com/topic/56766-email-form/#findComment-280374
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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