Riley Murphy Posted August 3, 2009 Share Posted August 3, 2009 First of all, hello! I'm so glad I found this place! My website is almost ready and getting this thing working is the last thing I need to do before it's declared open for business. Second, please be gentle. I'm a total newb. The mistake is probably something completely, profoundly stupid. I wrote a bit of PHP when I was in school, but haven't picked it up in several years now, and my knowledge is simplistic at the very best. I actually picked it up again just to get this site working. For context, it's a kind of travel-based project. Finally, the problem is that it seems like the code below does everything except gather the information. It redirects to the page acknowledging the email submission. It does in fact send the email, promptly and to the correct address. But the email only contains the sort of "filler" text and none of the user-submitted information. I've juggled it around a bit, but now I'm out of ideas and afraid of breaking it more. It should be a piece of cake for you guys, though, so can anyone see what's going wrong here? (I checked the names of the fields, and they all match.) <?php $name = $REQUEST['name']; $place = $REQUEST["place"]; $dare = $REQUEST["dare"]; $email = $REQUEST["email"]; mail( "dares@heyhitchhiker.com", "Hey, Hitchhiker!", "Someone called $name thinks you should go to $place for the purposes of $dare. You can get back to them at $email.", "From:$email" ); header( "Location: daresubmitted.html"); ?> Quote Link to comment Share on other sites More sharing options...
timmah1 Posted August 3, 2009 Share Posted August 3, 2009 Try this <?php $name = $_POST['name']; $place = $_POST["place"]; $dare = $_POST["dare"]; $email = $_POST["email"]; mail( "dares@heyhitchhiker.com", "Hey, Hitchhiker!", "Someone called {$name} thinks you should go to {$place} for the purposes of {$dare}. You can get back to them at {$email}.", "From:$email" ); header( "Location: daresubmitted.html"); ?> Quote Link to comment Share on other sites More sharing options...
Riley Murphy Posted August 3, 2009 Author Share Posted August 3, 2009 I copied it over, and when I tested the form again, the same thing happened. Quote Link to comment Share on other sites More sharing options...
timmah1 Posted August 3, 2009 Share Posted August 3, 2009 Try <?php $to = "dares@heyhitchhiker.com"; $subject = "Hey, Hitchhiker!"; $message = "Someone called '".$_POST['name']."' thinks you should go to '". $_POST["place"]."' for the purposes of '".$_POST["dare"]."'. You can get back to them at '".$_POST["email"]."'." $from = "$email"; mail($to, $subject, $message, $_POST["email"]); header( "Location: daresubmitted.html"); ?> Quote Link to comment Share on other sites More sharing options...
Riley Murphy Posted August 3, 2009 Author Share Posted August 3, 2009 I got this error when I changed the script and tested the form again: Parse error: syntax error, unexpected T_VARIABLE in sendmail.php on line 5 Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted August 3, 2009 Share Posted August 3, 2009 Try this.. <?php $name = $REQUEST['name']; $place = $REQUEST["place"]; $dare = $REQUEST["dare"]; $email = $REQUEST["email"]; $to = 'dares@heyhitchhiker.com'; $subject = 'Hey, Hitchhiker!'; $headers = 'From: ' . $email . "\r\n"; $message = 'Someone called '.$name.' thinks you should go to '.$place.' for the purposes of '.$dare.'. You can get back to them at '.$email.'.'; mail($to, $subject, $message, $headers); header( "Location: daresubmitted.html"); And the syntax error came from that if you copied timmahs code bcause he didnt have semicolon in the end of the line 4. Quote Link to comment Share on other sites More sharing options...
Riley Murphy Posted August 3, 2009 Author Share Posted August 3, 2009 Same result as it started with: sends the email with only the filler text. EDIT: Noticed what you said about the semicolon, added it in. That time, the email went through with ' ' in place of the words from the form. That's new. Before it was just blank. Quote Link to comment Share on other sites More sharing options...
watsmyname Posted August 3, 2009 Share Posted August 3, 2009 Same result as it started with: sends the email with only the filler text. try this , it should be $_REQUEST, you have $REQUEST <?php $name = $_REQUEST['name']; $place = $_REQUEST["place"]; $dare = $_REQUEST["dare"]; $email = $_REQUEST["email"]; $to = 'dares@heyhitchhiker.com'; $subject = 'Hey, Hitchhiker!'; $headers = 'From: ' . $email . "\r\n"; $message = 'Someone called '.$name.' thinks you should go to '.$place.' for the purposes of '.$dare.'. You can get back to them at '.$email.'.'; mail($to, $subject, $message, $headers); header( "Location: daresubmitted.html"); Quote Link to comment Share on other sites More sharing options...
Riley Murphy Posted August 3, 2009 Author Share Posted August 3, 2009 It's posting with the blanks instead of the ' ' again. I'm not sure which is a better sign. Quote Link to comment Share on other sites More sharing options...
WolfRage Posted August 3, 2009 Share Posted August 3, 2009 Let's see the form, sounds like your form is incorrect. Also you need to look into security of that form or else you will get hacked. Never trust client input! Quote Link to comment Share on other sites More sharing options...
timmah1 Posted August 3, 2009 Share Posted August 3, 2009 Change your form enctype to this <form action="sendmail.php" method="post" enctype="application/x-www-form-urlencoded"> instead of this <form action="sendmail.php" method="post" enctype="text/plain"> This worked fine for me Quote Link to comment Share on other sites More sharing options...
Riley Murphy Posted August 3, 2009 Author Share Posted August 3, 2009 Aha! That did it, the test worked. Thank you so much, everyone! As far as security goes, that's pretty obviously way over my head on my own. Do you know anywhere I could read about something to do about that? Also, how does one mark a thread as solved? Quote Link to comment Share on other sites More sharing options...
WolfRage Posted August 3, 2009 Share Posted August 3, 2009 http://www.phpfreaks.com/forums/index.php/topic,262956.msg1240983.html#new 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.