rsrwebs Posted June 9, 2009 Report Share Posted June 9, 2009 (edited) Well, I had posted this question on another forum besides this one, and somebody told me that the IDs for each field are case sensitive! So what I had as $_POST['name'] was supposed to be $_POST['Name'] because I capitalized the first letters. Man, I feel so silly, but thank you all so much for helping me out, it means a lot! (Original Message:) Hi, I am working on a page where you fill out a form to sign up for an email newsletter. Sending an email alone is no problem, but the text entered into the form does not show up when I run a test. I know it probably has to do with how the info is being posted, but I haven't the slightest clue what code is missing/incorrect. All I'm trying to do is have the information entered into the form be in the body of the email the PHP sends out. Here's the form page: http://www.laurendragon.com/mailinglistform.php The code I'm using: <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> Name (First & Last): City: State: Email: Here is the sendemail.php code: <?php $to="Laurendragon@laurendragon.net"; $subject="Mailing List Signup"; $body=" Name $name City $city State $state Email $email"; mail($to,$subject,$body); ?> Any help is much appreciated. I apologize if I'm not making much sense, my mind is clogged today. -Raven Edited June 12, 2009 by rsrwebs Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted June 10, 2009 Report Share Posted June 10, 2009 Gather your information from the POST array $body=" Name $_POST['name'] City $_POST['city'] State $_POST['state'] Email $_POST['email']"; Quote Link to comment Share on other sites More sharing options...
rsrwebs Posted June 11, 2009 Author Report Share Posted June 11, 2009 (edited) <?php$to="Laurendragon@laurendragon.net";$subject="Mailing List Signup";$body="Name $_POST['name']City $_POST['city']State $_POST['state']Email $_POST['email']";mail($to,$subject,$message);?>Thank you! Edited June 11, 2009 by rsrwebs Quote Link to comment Share on other sites More sharing options...
Wickham Posted June 11, 2009 Report Share Posted June 11, 2009 (edited) I don't think the words Name City etc should be in there at all on their own. Try $name = $_POST['name'] to create a variable $name created from the form by $_POST['name'] the 'name' field in the form (possibly with ; at the end depending onwhether it's the last item of an instruction). Edited June 11, 2009 by Wickham Quote Link to comment Share on other sites More sharing options...
rsrwebs Posted June 11, 2009 Author Report Share Posted June 11, 2009 (edited) Just tried that and got another error. God, this is so confusing... Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in sendemail.php on line 15 I'm pretty sure that's the same message too, I'm going to check though my form again and make sure my labels are right. (The labels are correct, I'm at a loss) Edited June 11, 2009 by rsrwebs Quote Link to comment Share on other sites More sharing options...
rsrwebs Posted June 11, 2009 Author Report Share Posted June 11, 2009 Would it have to do with the input type maybe? For each field, this is the code I have: Do you think I may need to add something to that? Like method="$_POST"? I dunno, that may be redundant, because at the top of the code for the whole form is PHP is a B!tch! Lmao. Quote Link to comment Share on other sites More sharing options...
rsrwebs Posted June 11, 2009 Author Report Share Posted June 11, 2009 I tried this code here: $body = "Name: ".$_POST['name']."\r\n"; $body .= "City: ".$_POST['city']."\r\n"; $body .= "State: ".$_POST['state']."\r\n"; $body .= "Email: ".$_POST['email']."\r\n"; The error message is gone, and the email sends again, but the info put into the form still doesn't get sent. This is what I end up seeing: Name: City: State: Email: Arrgg... Well, I dunno if I said this yet, but thanks to everyone helping me out on this... Quote Link to comment Share on other sites More sharing options...
Wickham Posted June 12, 2009 Report Share Posted June 12, 2009 I'm glad you got it sorted, it's often the simplest things. However, I was a bit worried about repeating $body four times in your last post so I did a bit of experimenting with my own form. You can simplify it:- $body = "Name: ".$_POST['name']."\r\n"."City: " .$_POST['city']."\r\n"."State: ".$_POST['state']."\r\n"."Email: ".$_POST['email']; Quote Link to comment Share on other sites More sharing options...
rsrwebs Posted June 13, 2009 Author Report Share Posted June 13, 2009 Repeating $body doesn't seem to be causing any trouble, but thanks for the simplification. Quote Link to comment Share on other sites More sharing options...
Guest kindbear Posted July 1, 2009 Report Share Posted July 1, 2009 $body="Name $_POST['name'] City $_POST['city'] State $_POST['state'] Email $_POST['email']"; mail($to,$subject,$message); 1. Replace $message by the $body 2. Try this, it's really working :-) : $body = "Name: ".$_POST['name']."\r\n"."City: " .$_POST['city']."\r\n"."State: ".$_POST['state']."\r\n"."Email: ".$_POST['email']; 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.