[SOLVED] error message help!!!
Posted: Sun Feb 27, 2005 9:56 pm
hi there
i have this code:
the problem is, when i try not to input anything in the textfield and textarea, the error messages does not appear and the only error message is the 'TRY AGAIN' message, and instead of that message appearing in red, it appears to be black.what could be the problem with my code?
i cant seethe problem within this code, and i tried to read each line, compared it my other code, it seems to be good, but i spent so much time looking for the problem....hope u guys can help me...
thanks.
pleigh
i have this code:
Code: Select all
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<form action="<? $_SERVERї'PHP_SELF']; ?>" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<!--spacer-->
<tr>
<td width="20%"> </td>
<td width="1%"> </td>
<td width="79%">
<?
$id = $_SESSIONї'userID'];
//submit conditionals
if (isset($_POSTї'submit']))
{
$errormessage = NULL;
//verify title
if (empty($_POSTї'topic']))
{
$t = FALSE;
$errormessage .= 'Enter the title of your report!<br>';
}
else
{
$t = addslashes($_POSTї'topic']);
}
//verify accomplishment
if (empty($_POSTї'message']))
{
$m = FALSE;
$errormessage .= 'Enter your accomplishment report!<br>';
}
else
{
$m = addslashes($_POSTї'message']);
}
if ($t && $m)
{
$query = "INSERT INTO forum(userID, topic, message, date)
VALUES('$id','$t','$m', NOW())";
$result = @mysql_query($query);
if ($result)
{
echo '<b>Your report has been recorded</b>';
echo '<meta http-equiv="refresh" content="3;url=http://localhost/mysample/forum.php">';
exit();
}
else
{
$errormessage .= 'Your report cannot be recorded due to system error<br>'.mysql_error();
}
mysql_close();
}
else
{
$errormessage = 'Please try again<br>';
}
}
if (isset($errormessage))
{
echo '<font="red">', $errormessage, '</font>';
}
?>
</td>
</tr>
<!--title-->
<tr>
<td width="20%" align="right"><b>TOPIC</b></td>
<td width="1%"><b>:</b></td>
<td width="79%"><input type="text" name="topic" value="<? if (isset($_POSTї'topic'])) echo $_POSTї'topic']; ?>"></td>
</tr>
<!--accomplishments-->
<tr valign="top">
<td width="20%" align="right"><b>MESSAGE</b></td>
<td width="1%"><b>:</b></td>
<td width="79%"><textarea name="message" cols="40" rows="6"></textarea></td>
</tr>
<tr valign="top">
<td width="20%"></td>
<td width="1%"></td>
<td width="79%"><input type="submit" name="submit" value="submit report"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>i cant seethe problem within this code, and i tried to read each line, compared it my other code, it seems to be good, but i spent so much time looking for the problem....hope u guys can help me...
thanks.
pleigh