Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have a simple contact form on a website that has 2 text fields, 1 textarea, and 1 hidden field.

For some reason, all the fields POST to a PHP script except the textarea. I have done this a thousand times before and never had this issue.

Here is my HTML:

<form action="scripts/contactform.php" method="post">
<table width="0" border="0" cellspacing="3" cellpadding="5" class="gpass">
  <tr>
    <td>Name:</td>
    <td><input name="name" type="text" maxlength="50" /></td>
  </tr>
  <tr>
    <td>E-mail:</td>
    <td><input name="email" type="text"/></td>
  </tr>
  <tr>
    <td>Message:</td>
    <td><textarea name="comment" id="comment" cols="30" rows="5"></textarea>
    <input type="hidden" value=" <?php echo $_SERVER['REMOTE_ADDR'];?>" name="address" />
    </td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input name="submit" type="submit" value="Submit" class="noround" id="regbut" /><input name="reset" type="reset" value="Reset" class="noround" id="regbut"/></td>
  </tr>
</table>
</form>

And my script looks like this:

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) 
{
    die('Failed to connect to server: ' . mysql_error());
}

$db = mysql_select_db(DB_DATABASE);
if(!$db) 
{
    die("Unable to select database");
}

$name = mysql_real_escape_string($_POST['name']);
$email = mysql_real_escape_string($_POST['email']);
$comment = mysql_real_escape_string($_POST['comment']);
$ipaddress = mysql_real_escape_string($_POST['address']);

I have a few things to process the data underneath this, but that doesn't matter since the $comment variable isn't being defined. I've searched the entire script and there are no conflicting variable names.

I am completely stumped on why this is happening. I've successfully processed textarea's on my site multiple times before, so this really is confusing.

share|improve this question
1  
What does var_dump($_POST) show? – Marc B Jan 3 '12 at 22:00
    
What do you see if you do a print_r($_POST)? – swatkins Jan 3 '12 at 22:00
    
Where do you use the comment data (I can't see it in your code)? What is in the $_POST superglobal? E.g. var_dump($_POST); – PeeHaa Jan 3 '12 at 22:02
1  
Whoa! "message" or "comment"? Which is it? – Ayman Safadi Jan 3 '12 at 22:09
1  
@AndrewDeForest in your HTML you used comment as name but in your dump you say you have message as name. I say PEBKAC. – PeeHaa Jan 3 '12 at 22:12
up vote 2 down vote accepted

I once experienced an error similar to yours. What helped me was to use different id and name parameters. Try and see for yourself, because you have them identical here.

share|improve this answer
    
Wow, for some reason this worked! Any idea why? I will mark this as answered in a few minutes, just have to wait for the timer. Thanks! – Andrew De Forest Jan 3 '12 at 22:05
1  
No idea, really ... But when that happened to me, I was freaking out and just tried to assign a different id to my field. I was shocked it worked for me back then. – Pateman Jan 3 '12 at 22:07
    
Are you using HTML 5? – craig1231 Jan 3 '12 at 22:08
5  
This goes against everything I believe in! – Ayman Safadi Jan 3 '12 at 22:08
    
@craig1231, it happened to me way before HTML5 became known. – Pateman Jan 3 '12 at 22:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.