Jump to content

Form Submission Issues


Riley Murphy

Recommended Posts

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. :shrug: 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( "[email protected]", "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");

?>

Link to comment
https://forums.phpfreaks.com/topic/168648-form-submission-issues/
Share on other sites

Try this

 

<?php
$name = $_POST['name'];
$place = $_POST["place"];
$dare = $_POST["dare"];
$email = $_POST["email"];

mail( "[email protected]", "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");

?>

Try

<?php
$to = "[email protected]";
$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");
?>

Try this..

 

<?php
$name = $REQUEST['name'];
$place = $REQUEST["place"];
$dare = $REQUEST["dare"];
$email = $REQUEST["email"];

$to = '[email protected]';
$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.

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.

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 = '[email protected]';
$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");

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?

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.