lisacleverley Posted June 22, 2007 Share Posted June 22, 2007 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@exampleemail.com"; $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 Quote Link to comment https://forums.phpfreaks.com/topic/56766-email-form/ Share on other sites More sharing options...
SycoSyco Posted June 22, 2007 Share Posted June 22, 2007 First this is your page is .htm not .php Quote Link to comment https://forums.phpfreaks.com/topic/56766-email-form/#findComment-280345 Share on other sites More sharing options...
lisacleverley Posted June 22, 2007 Author Share Posted June 22, 2007 Edited first post as I had put .htm rather than .html It's not a php page. It's a html page with a php email form. However the email form is not working which is why I'm posting. I can't see in the coding why it's not working Lisa Quote Link to comment https://forums.phpfreaks.com/topic/56766-email-form/#findComment-280349 Share on other sites More sharing options...
SycoSyco Posted June 22, 2007 Share Posted June 22, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/56766-email-form/#findComment-280359 Share on other sites More sharing options...
SycoSyco Posted June 22, 2007 Share Posted June 22, 2007 I just ran your script and it sent OK Quote Link to comment https://forums.phpfreaks.com/topic/56766-email-form/#findComment-280362 Share on other sites More sharing options...
lisacleverley Posted June 22, 2007 Author Share Posted June 22, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/56766-email-form/#findComment-280365 Share on other sites More sharing options...
SycoSyco Posted June 22, 2007 Share Posted June 22, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/56766-email-form/#findComment-280374 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.