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.
var_dump($_POST)show? – Marc B Jan 3 '12 at 22:00print_r($_POST)? – swatkins Jan 3 '12 at 22:00commentdata (I can't see it in your code)? What is in the$_POSTsuperglobal? E.g.var_dump($_POST); – PeeHaa Jan 3 '12 at 22:02commentas name but in your dump you say you havemessageas name. I say PEBKAC. – PeeHaa Jan 3 '12 at 22:12