Yesterday I setup a message/note script for a "view project" page. It seemed to work fine. Today I went to test it out a bit more and on random occasions I get stuck in a confirm loop.
Screenshot: http://rawrgv.com/images/screenlnl.png
I tried unsetting the form submit variable, but that doesn't seem to do anything.
Code:
<?
if(isset($_POST['newnote'])){
$uid = $_POST['uid'];
$oid = $_POST['oid'];
$level = $_POST['level'];
$note = $_POST['note'];
$result = mysql_query("INSERT INTO notes (uid, oid, level, note) VALUES ('$uid', '$oid', '$level', '$note') ") or die(mysql_error());
if($result){
unset($_POST['newnote']);
echo "<meta http-equiv=\"Refresh\" content=\"0;url=$HTTP_SERVER_VARS[PHP_SELF]?id={$orderID}\">";
}
else{
echo "<BR /><BR />Submission Failed";
}
}
else{
$getComments = mysql_query("SELECT * FROM notes WHERE oid = '$oid' ORDER BY time");
$comCount = 0;
while($commentRow = mysql_fetch_assoc($getComments)){
$level = $commentRow['level'];
if($level == 1)
$level = "<font color='black'>Appraiser</font>";
else if($level == 2)
$level = "<font color='blue'>Client</font>";
else if($level == 3)
$level = "<font color='red'>Admin</font>";
else
$level = "Unknown";
$comCount++;
?>
<p><? echo $level; echo ": "; echo $commentRow['note']; ?><BR />----------------------<BR /></p>
<?
} //end while
/*if($comCount == 0){
?>
<p><? echo "No Notes"; ?><BR /></p>
<?
} */ //end if
?>
<form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; echo "?id={$orderID}"; ?>" method="post">
<br />
<div class="shadowDivider"> </div>
<div class="formRow">
<textarea name="note" cols="50" rows="5" onclick="this.value = '';">Enter your note here...
</textarea>
<input type="hidden" name="uid" value="<? echo $userID; ?>" />
<input type="hidden" name="oid" value="<? echo $orderID; ?>" />
<input type="hidden" name="level" value="<? echo $userAccount; ?>" />
</div><!--end formRow-->
<div id="buttons">
<input type="submit" value="Submit" class="button" name="newnote" />
<? //<input type="button" value="County Serviced" class="button" /> ?>
</div><!--end buttons-->
</form>
<BR /><BR /><BR /><BR /><BR />
<?
}
?>