I have a simple form that gathers info from a textbox (message). It checks if it's not blank and if not, stores 'message' and the date into MySQL. The problem is, it's only storing the date and not the message. Here's the script:
// php in the beginning of the file
<?
if($submit){
$flag = true;
include "../includes/connect.php";
$date = date("m . d .y");
if(empty($message) || $message = "")
$error = "Please enter a message.";
if(!$error){
$query = "INSERT INTO updates set id = NULL, date = \"" . $date . "\", message = \"" . $message . "\"";
mysql_query($query, $conn);
}
}
?>
// later in the html, form that gathers user input
<form action="" method="post" name="update" id="update">
<input name="submit" type="hidden" value="submit">
<table width="373" border="0" cellspacing="0" cellpadding="2">
<tr class="global">
<td width="64" align="right" valign="top">Message</td>
<td width="301" align="left" valign="top"> <textarea name="message" cols="50" rows="8" class="textbox" id="message"></textarea>
</td>
</tr>
<tr class="global">
<td> </td>
<td><br> <input type="submit" name="Submit" value="Post Update">
</td>
</tr>
</table>
</form>
// display script right beneath the form
<?
if($flag){
if($error)
echo "<span class='notes'>".$error."</span>";
else
echo "<span class='notes'>This is the message you've posted:<br><br>".$date."<br>".$message."</span>";
}
?>