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

时间:2013-03-05 23:03:22

标签: php html http redirect header

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

enter image description here

编辑文本后,点击用当前替换上一个音符:

enter image description here

使用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将用户重定向回同一页面并显示以下注释:

enter image description here

我遇到的问题是:

  1. 原始笔记在文本框中消失,现在文本框为空白,如上所示
  2. 如果我点击replace previous note with current 重新,我会得到与上面#1相同的结果,此外,文本框中的内容是 NOT < / strong>保存到数据库。
  3. 这是包含文本框的页面代码(编辑或删除注释):

    <!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的东西?

3 个答案:

答案 0 :(得分:1)

从我看到的情况来看,你设置了其他情况

else
{
   $Comment='';
}

你进入其他案件的原因如下:

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

$arr['a'] = 'a';
echo $arr['A']; //echoes blank (false)

与你的案子:

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

所以我会在尝试获取值时将comid更改为大写。

答案 1 :(得分:1)

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

答案 2 :(得分:1)

 $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.");