Php 重新打开页面时,内容不会刷新

Php 重新打开页面时,内容不会刷新,php,html,http,redirect,header,Php,Html,Http,Redirect,Header,打开此页面时,将在下面的文本框中显示记录的内容: 编辑文本并单击“将以前的注释替换为当前注释”后: 使用ModifyNoteScript.php中的以下代码将记录成功存储在数据库中: 标题将用户重定向回同一页面,并显示此注释: 我遇到的问题是: 原始注释消失在文本框中,现在文本框为空白,如上图所示 如果我再次单击“用当前注释替换以前的注释”,我会得到与上面1相同的结果,此外,文本框中的内容不会保存到数据库中。 以下是使用文本框编辑或删除注释的页面代码: <!DOCTYPE html PUB

打开此页面时,将在下面的文本框中显示记录的内容:

编辑文本并单击“将以前的注释替换为当前注释”后:

使用ModifyNoteScript.php中的以下代码将记录成功存储在数据库中:

标题将用户重定向回同一页面,并显示此注释:

我遇到的问题是:

原始注释消失在文本框中,现在文本框为空白,如上图所示 如果我再次单击“用当前注释替换以前的注释”,我会得到与上面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>

我做错了什么?我怀疑是头部有问题?

从我看到的情况来看,是您在其他情况下设置的

else
{
   $Comment='';
}
您进入else案例的原因如下:

您可以使用小写字母访问$\u GET['comid'],但当您将其设置为大写字母&comid=。我尝试了以下方法:

$arr['a'] = 'a';
echo $arr['A']; //echoes blank (false)
就你的情况而言:

$_GET['COMID'] = 'test';
var_dump($_GET['comid']); // results in undefined index comid

因此,在尝试获取该值时,我会将comid改为大写。

从我看到的情况来看,您是在其他情况下设置的

else
{
   $Comment='';
}
您进入else案例的原因如下:

您可以使用小写字母访问$\u GET['comid'],但当您将其设置为大写字母&comid=。我尝试了以下方法:

$arr['a'] = 'a';
echo $arr['A']; //echoes blank (false)
就你的情况而言:

$_GET['COMID'] = 'test';
var_dump($_GET['comid']); // results in undefined index comid

因此,在尝试获取值时,我会将comid改为大写。

尝试在$Comment='Test'中添加一些文本,这样您就可以知道mssql_num_行何时返回0行。

尝试在$Comment='Test'中添加一些文本,这样您就可以知道mssql_num_行何时返回0行。

非常感谢。我听从了你的建议。我做了这个$_GET['COMID']='test';事实上,它正在回归“测试”!但是,这没有意义,因为当我查看数据库时,它确实有一个值,字段类型是COMID int还是varchar@kingdomcreation我没有具体说明!但是在数据库中,它是一个整数,你应该尝试删除引号。。。那么单位呢?一个整数也有这么多。我听从了你的建议。我做了这个$_GET['COMID']='test';事实上,它正在回归“测试”!但是,这没有意义,因为当我查看数据库时,它确实有一个值,字段类型是COMID int还是varchar@kingdomcreation我没有具体说明!但是在数据库中,它是一个整数,你应该尝试删除引号。。。单位是一个整数吗?在跟踪sql之后,我从pmp_属性_uuUnit中得到了select top 1注释,其中communityidy='40'和unit=因此看起来$unit没有从标题'Location:ModifyNote.php?unit='成功传递过来$单位&COMID='$来吧。”&成功='$成功在跟踪sql之后,我从pmp_属性_uuunit(其中communityidy='40'和unit=)中获得了select top 1注释,因此看起来$unit没有从标题“Location:ModifyNote.php?unit=”成功传递$单位&COMID='$来吧。”&成功='$成功
 $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.");