0

I finally have it so that when I click the submit button, I do get an email, but all that shows up is: "Name:". It doesn't tell me what the name is, or show the other two fields. (It does go to the Thank You page OK.) What am I doing wrong? Thanks in advance.

Here's the form html:
<form name="contactform" method="post" action="send_form_email.php">
<fieldset>
<legend>What shall we call it?</legend>
<label for="Name">Your name or screen-name:</label>
<input type="text" name="name" id="Name"/><br /><br />
<label for="Comment">
Comments: </label> <br /><br />
<textarea name="comment" id="Comment" cols="60" rows="6"></textarea>
<br /><br />
<label for="Studyname">
Suggested study name: </label><input type="text" name="studyname" id="Studyname" size="60" /><br />
<br />
<input type="Submit" value="Send" /><br />
<input type="Reset" value="Clear" /><br />
</fieldset>
</form>

Here's what I have for the php, using a simple example I found online, and modifying it for my form:
<?php
{
$name = $_REQUEST;
$comment = $_REQUEST;
$studyname = $_REQUEST;

mail( "myemail@gmail.com", "Study Name",
"Name: $name",
"Comment: $comment",
"Studyname: $studyname");

header( "Location: http://mywebsite.us/ThankYou.html" );
}
?>

3
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by tearose49
0

I think there may be something missing in the php part of your script.

$email = $_REQUEST['email'] ;

It should come here:

<?php
  $email = $_REQUEST['email'] ;

Followed by the rest, and then here

mail( "myemail@gmail.com", "Study Name",

it should look something like this:

]mail( "myemail@gmail.com", "Study Name", $message, "From: $email" );

header( "Location: http://mywebsite.us/ThankYou.html" );
}
?>

So what I recon, your script should then look like this:

<?php
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'];
$comment = $_REQUEST['comment'];
$studyname = $_REQUEST['studyname'];

mail( "myemail@gmail.com", "Study Name",
$message, "From: $email" );

header( "Location: http://mywebsite.us/ThankYou.html" );
?>

But, I may be wrong.

0

In your code, this is wrong i think...

mail( "myemail@gmail.com", "Study Name",
"Name: $name",
"Comment: $comment",
"Studyname: $studyname");

Obviously, the mail() function syntax is mail($to,$subject,$message,$headers);

Isnt it..? But you gave Name, Comment, Studyname like that..

First of all, you have to store the message in a separate variable (e.g $message) that you need to send. Then, try to append it in mail function. It will definitely works.

Hope you can understand this. If still problem occurs, please let me know...

0

Thanks for trying, but with those changes, it doesn't send the email or go to the thank you page.

0

I just saw your comment, Dragonbaki. My previous response was to Kraai.
I think I understand what you're saying, but I'm not quite sure how to do it. You're saying I need something like:
$message= "Name: $name",
"Comment: $comment",
"Studyname: $studyname"

Not sure about the syntax in that. And I don't understand about the headers. In the example I was studying, the sender's email was requested, and that's what was in the headers position. I didn't request the sender's email. Do I need to put something there?

0

Just comment the header function and try to run that program... If suppose any error in mail() function, you will get.. Post that error... we will discuss abt that...

0

I tried using the syntax I found in another discussion on this forum, but still no joy.
Here's how I have the php now:

<?php
$to = "myemail@gmail.com";
$name = $_REQUEST;
$comment = $_REQUEST;
$studyname = $_REQUEST;
$message = "From: $name Comment: $comment" Studyname: $studyname" ;

mail( $to, "Rose Study Name", $message, "anonymous@server.sureserver.com");

header( "Location: http://heritageroses.us/ThankYou.html" );

?>

And here's the error message I get:

Parse error: syntax error, unexpected T_STRING in /home/mywebsite/www/www/send_form_email.php on line 6

That's the $message line. The one I used as reference also had \n\n after the first 2 items in message, but when I tried that, I got 2 error messages.

I looked up that message, but the things I found didn't help me.

0

Yes.. You have syntax error in your code... See the following actual line you posted.

$message = "From: $name Comment: $comment" Studyname: $studyname" ;

This line consists of only 3 double quotes.. which means you did not handle the quotes correctly...

$message = "From: $name <br> Comment: $comment <br> Studyname: $studyname" ;

Replace the above line with line 6... If still problem occurs., pls let me know...

0

Much improved! Thanks. Can't believe I didn't notice that ". However, now that it is sending me an email, here is what is in the email:

From: <br> Comment: <br> Studyname:

I'm assuming the breaks don't work because the page is a .php page, not html. But I don't know why it doesn't print the contents of $name, $comment and $studyname.

0

Never mind- it was the html in the form- still had capital letters in the id field. I made them lower case, and now it sends the info. Thanks so much for your help debugging my code!
Tearose49

Much improved! Thanks. Can't believe I didn't notice that ". However, now that it is sending me an email, here is what is in the email:

From: <br> Comment: <br> Studyname:

I'm assuming the breaks don't work because the page is a .php page, not html. But I don't know why it doesn't print the contents of $name, $comment and $studyname.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.