By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 2,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

PHP Form sending blank

P: 2
Hi,

I made a php form and when it sends the data is blank.

it just shows

Name:
Email:
Number:
Comments:

Help!!!!!!!!!

Thanks!!


<?php

/* Subject and Email Variables */

$emailSubject = 'TheChallahFairy!';
$webMaster = 'nicole.frenkel@gmail.com';

/* Gathering Data Variables */

$nameField = $_POST['name'];
$numberField = $_POST['number'];
$emailField = $_POST['email'];
$commentsField = $_POST['comments'];

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Number: $number <br>
Email: $email <br>
Comments: $comments <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);






<form action="contactsending.php" method="post" name="form" id="form">
<p>&nbsp;</p>
<p>Name<br />
<input name="name" type="text" size="30" id="name" />
<br />
<br />
Telephone Number<br />
<input name="number" type="text" size="30" id="number" />
<br />
<br />
Email Address<br />
<input name="email" type="text" size="20" id="email" />
<br />
<br />
Comments<br />
<textarea name="comments" cols="40" rows="8" id="comments">
</textarea>
<br />
<br />
<input type="submit" value="Send" />
</p>
</form>
Dec 7 '11 #1
Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,347
That's because your variable is called $nameField, not $name, etc.
Dec 7 '11 #2

P: 78
You can use
echo "Name:";
echo $name;
echo "<br>";

OR

echo "Name:".$_POST['name'];
Dec 7 '11 #3

P: 2
Thank you it worked!
Dec 7 '11 #4

Rabbit
Expert Mod 10K+
P: 12,347
Please mark the post that worked as the answer.
Dec 7 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.