Jump to content

PHP Form-to-Email doesn't send input (UPDATE! Resolved!)


rsrwebs

Recommended Posts

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. :lol: Man, I feel so silly, but thank you all so much for helping me out, it means a lot! :D

 

(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 by rsrwebs
Link to comment
Share on other sites




<?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 by rsrwebs
Link to comment
Share on other sites

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 by Wickham
Link to comment
Share on other sites

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 by rsrwebs
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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... :)

Link to comment
Share on other sites

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'];

Link to comment
Share on other sites

  • 3 weeks later...
Guest kindbear
$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'];
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...