当这个页面打开时,它会在下面的文本框中显示一条记录的内容:
在我编辑文本并单击将以前的注释替换为当前注释后:
使用以下代码将记录成功存储在数据库中ModifyNoteScript.php
:
$comment_update = mssql_query("UPDATE pmp_property__unit
SET
comments = '$NOTE'
WHERE
communityidy='$COMID' and
unit='$UNIT'")
or die ("Changes to Record could not be Saved.");
if (!$comment_update)
{
$success=2;
}
else
{
$success=1;
}
header ('Location:ModifyNote.php?unit=' . $UNIT . '&COMID=' . $COMID . '&success=' . $success);
将header
用户重定向回同一页面并显示此注释:
我遇到的问题是:
- 原来的注释在文本框中消失了,现在文本框是空白的,如上所示
replace previous note with current
如果我再次单击,我会得到与上面相同的结果#1
,此外,文本框中的任何内容都不会保存到数据库中。
这是带有文本框的页面的代码(编辑或删除注释):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../nav/occupancypop.css" rel="stylesheet" type="text/css"></link>
<script type='text/JavaScript' src='../scw.js'></script></head>
<script type="text/javascript">
<!--
function closewindow() {
parent.location = "occupancy2.php"
}
//-->
</script>
<body>
<div id="maincontentform">
<?php
include '../Check.php';
$success = $_GET['success'];
if($success == 1)
{
echo '<span class="style4">*The note has been saved!</span><br />
<br />';
}
elseif ($success==2)
{
echo '<span class="style4">*There was an error updating the note!</span><br />
<br />';
}
//GET the unit and community id
$UNIT = $_GET['unit'];
$COMID = $_GET['comid'];
include '../KiscoCustomConnect.php';
//Get the commnet
$Comment_Query = mssql_query("select top 1 comments from pmp_property__unit where communityidy='$COMID' and unit='$UNIT'");
if (mssql_num_rows($Comment_Query)>0)
{
$Comment=mssql_result($Comment_Query,0,'comments');
}
else
{
$Comment='';
}
?>
<span class="MainTitle">
Edit or Delete the Note</span>
<p><br />
<table width="596" border="0" cellspacing="0" cellpadding="0" id="maintable">
<tr class="odd">
<td width="164"><div class="pickform">
<ul>
<li>
<div align="center">
<p><strong><img src="../media/_space.gif" alt="" width="135" height="1" /><br />
Update Notes</strong><br />
<?php echo 'for unit ' . $UNIT ?>
</div>
</li>
</ul>
</div></td>
<td width="431">
<form action="ModifyNoteScript.php" method="post" />
<input name="Comment" type="hidden" value="<?php echo $Comment; ?>" />
<input name="UNIT" type="hidden" value="<?php echo $UNIT; ?>" />
<input name="COMID" type="hidden" value="<?php echo $COMID; ?>" />
<textarea name="Comment" cols="55" rows="6" class="text1" id="Comment"><?php echo $Comment; ?></textarea>
<br />
<input type="submit" name="sendnotify" class="formbutton" id="Submit" value="Replace previous note with current" />
</form></td>
</tr>
</table>
<blockquote>
<p><br />
<?php
if($success == 3)
{
echo '<input type="button" name="Cancel3" class="formbutton2" id="Cancel3" value="Close" onclick="closewindow2();" />';
}
else
{
echo '<input type="button" name="Cancel3" class="formbutton2" id="Cancel3" value="Close" onclick="closewindow();" />';
}
?> <br />
<br />
</p>
</blockquote>
</div>
</body>
</html>
我究竟做错了什么?我怀疑它与header
?