julieb Posted January 22, 2009 Share Posted January 22, 2009 I have a newsletter request form with only an email being sent. For some reason it is not working. I would really appreciate it, if I could get some help. Thank you so much in advance. Here is the php I have: <? $to = "[email protected]"; $from_header = "From: $from"; if($contents != "") { //send mail - $textfield come from surfer input mail($to, $textfield, $from_header); // redirect back to url visitor came from header("Location: $HTTP_REFERER"); } else { print("<HTML><BODY>Error, no comments were submitted!"); print("</BODY></HTML>"); } ?> Here is the html code I have: <form action="send_email.php3" method="POST"> <label> <input type="text" name="textfield" id="textfield" /> </label> <label> <input type="submit" name="button" id="button" value="Submit" /> </label> <div align="right"></div> </form> Thank you so much again. Here is the site that it is on. http://epistrophikpeachsound.com/links/ at the bottom right. Link to comment https://forums.phpfreaks.com/topic/141977-email-submission-for-newsletter/ Share on other sites More sharing options...
julieb Posted January 22, 2009 Author Share Posted January 22, 2009 I really don't know php. I went online to a php tutorial. They had a php file and I tried to alter it to work with my form. Not sure what I did wrong. Link to comment https://forums.phpfreaks.com/topic/141977-email-submission-for-newsletter/#findComment-743403 Share on other sites More sharing options...
Philip Posted January 22, 2009 Share Posted January 22, 2009 Okay, there are a few things that are wrong here <?php $to = "[email protected]"; $from_header = "From: $from"; if($contents != "") { //send mail - $textfield come from surfer input mail($to, $textfield, $from_header); // redirect back to url visitor came from header("Location: $HTTP_REFERER"); } else { print("<HTML><BODY>Error, no comments were submitted!"); print("</BODY></HTML>"); } ?> Where is the $from defined in: $from_header = "From: $from"; And the $textfield needs to be $_POST['textfield'] since you're getting it from the form. So: <?php // Always be sure to use long tags (<?php, not <?) // Setup basic info $to = "[email protected]"; $from_header = "From: $from"; // Where is this coming from? // Check contents, again where is variable that coming from? if($contents != "") { //send mail - $textfield come from surfer input // dont forget $_POST mail($to, $_POST['textfield'], $from_header); // redirect back to url visitor came from // This isn't the most secure way, but that's okay for now. header("Location: $HTTP_REFERER"); } else { print("<HTML><BODY>Error, no comments were submitted!"); print("</BODY></HTML>"); } ?> Link to comment https://forums.phpfreaks.com/topic/141977-email-submission-for-newsletter/#findComment-743412 Share on other sites More sharing options...
julieb Posted January 22, 2009 Author Share Posted January 22, 2009 Hi there.... thank you for responding. I was just taking a send_email.php3 file that was online and tried to alter it. So I should take out the $from_header = "From: $from"; Duh, I dont have a "from" field. <?php // Always be sure to use long tags (<?php, not <?) // Setup basic info $to = "[email protected]"; // Check contents, again where is variable that coming from? if($contents != "") { //send mail - $textfield come from surfer input // dont forget $_POST mail($_POST['textfield']); // redirect back to url visitor came from // This isn't the most secure way, but that's okay for now. header("Location: $HTTP_REFERER"); } else { print("<HTML><BODY>Error, no comments were submitted!"); print("</BODY></HTML>"); } ?> I changed it but it is still not working.. the only thing that comes up is "Error, no comments were submitted!" I put in an email address in the textfield box?? Not sure what else to do.. THANK YOU SO MUCH... Okay, there are a few things that are wrong here <?php $to = "[email protected]"; $from_header = "From: $from"; if($contents != "") { //send mail - $textfield come from surfer input mail($to, $textfield, $from_header); // redirect back to url visitor came from header("Location: $HTTP_REFERER"); } else { print("<HTML><BODY>Error, no comments were submitted!"); print("</BODY></HTML>"); } ?> Where is the $from defined in: $from_header = "From: $from"; And the $textfield needs to be $_POST['textfield'] since you're getting it from the form. So: <?php // Always be sure to use long tags (<?php, not <?) // Setup basic info $to = "[email protected]"; $from_header = "From: $from"; // Where is this coming from? // Check contents, again where is variable that coming from? if($contents != "") { //send mail - $textfield come from surfer input // dont forget $_POST mail($to, $_POST['textfield'], $from_header); // redirect back to url visitor came from // This isn't the most secure way, but that's okay for now. header("Location: $HTTP_REFERER"); } else { print("<HTML><BODY>Error, no comments were submitted!"); print("</BODY></HTML>"); } ?> Link to comment https://forums.phpfreaks.com/topic/141977-email-submission-for-newsletter/#findComment-743450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.