DaveyBoy Posted February 10, 2009 Report Share Posted February 10, 2009 First let me say that I did not write this php code. I'm real new at trying to write and implement a php file and a "Join our mailing list" form. I can not see what's wrong so I am asking for some help. When I click the submit button on the web page I get nothing. No mail sent, just a blank page. Can someone look at the code(s) for me and maybe correct ? Here is the php code: <?PHP if($_POST['submit']) { $recipient="me@mywebsite.com"; $subject="My Web Site"; $body=" $name $email "; $headers='From: '.$email."\r\n".'Reply-to: '.$email."\r\n"; mail($recipient, $subject, $body, $headers); echo " "; } else { echo " "; } ?> And the form code: >Untitled Document </pre> <table width="63%" border="2" cellpadding="4">Join Our Mailing List NameEmailComments </table> <br Thanks for looking! Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted February 10, 2009 Report Share Posted February 10, 2009 $body= $_POST['comments']; $name = $_POST['name']; $email = $_POST['email']; Try that. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted February 10, 2009 Report Share Posted February 10, 2009 I'd need to play with the code... if you are getting a blank page, sounds like you have got an error. As I glanced over it, it looks like you're not setting the $name or $email vars anywhere -- that's the first thing I would change. You'll need to set their value using $_POST to grab the form data. Quote Link to comment Share on other sites More sharing options...
tpattison Posted February 10, 2009 Report Share Posted February 10, 2009 You need to fill the $email and $name variables with the contents of the form: <?PHP if($_POST['submit']) { $email = $_POST['email']; $name = $_POST['name']; $recipient="me@mywebsite.com"; $subject="My Web Site"; ... Also, your form has "Submit" while the PHP has "submit" with lower case "s", so change your form to read: Quote Link to comment Share on other sites More sharing options...
DaveyBoy Posted February 10, 2009 Author Report Share Posted February 10, 2009 (edited) jlhaslip and tpattison- I changed as instructed and I still get a blank page (mywebpage.com/sendmail2.php) when I submit... and no mail. Thanks falkencreative- Thanks for looking. Edited February 10, 2009 by DaveyBoy Quote Link to comment Share on other sites More sharing options...
DaveyBoy Posted February 11, 2009 Author Report Share Posted February 11, 2009 Thanks folks! I have"repaired" the code and now it works fine. I want to thank all that replyed and also Stefan Mischook for his tutorials on PHP. After viewing the tutorials I was able to see the error(s) and understand more about PHP code. Thanks again! Oh...Here is the repaired code. <?PHP if($_POST['submit']) { $recipient="me@mysite.com"; $subject="Contact from my Web Site"; $body=" $name $email $comments "; $headers='From: '.$email."\r\n".'Reply-to: '.$email."\r\n"; mail($recipient, $subject, $body, $headers); echo " "; } else { echo " "; } ?> Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.