Php 当我添加一条评论时,我得到了这个警告

Php 当我添加一条评论时,我得到了这个警告,php,mysql,comments,Php,Mysql,Comments,大家好,这个代码有问题 当id添加注释并在数据库中插入注释时 当我在同一页面上刷新时,我会收到以下警告: 其中一个字段仍然是空的, 我认为第一个代码中的问题 <?php if ($_POST['add'] and $_POST['add']=='comm'){ $comm_name =strip_tags($_POST['comm_name']); $comm_country =strip_tags(mysql_real_escape_s

大家好,这个代码有问题

当id添加注释并在数据库中插入注释时 当我在同一页面上刷新时,我会收到以下警告: 其中一个字段仍然是空的, 我认为第一个代码中的问题

    <?php 

    if ($_POST['add'] and $_POST['add']=='comm'){

    $comm_name      =strip_tags($_POST['comm_name']);
    $comm_country   =strip_tags(mysql_real_escape_string($_POST['comm_country']));
    $c              =strip_tags(mysql_real_escape_string($_POST['comm']));
    $comm_thread    =strip_tags(mysql_real_escape_string($_POST['comm_thread']));
    $status =$_POST['status'];
    $getidtopic=$_GET['id_topic'];
    $post_code=$_POST['post_code'];

    if ($comm_name=='' or $comm_country=='' or $c=='' or $post_code=='' ){
    echo "<script>alert(\"One of the fields are still empty
\");</script>";
    }else if ($_POST['post_code']==$_SESSION['code']) {

    $insertcomm=mysql_query("insert into comments values('','$comm_name','$comm_country','$comm','$comm_thread','$status') ")or die (mysql_error);
    echo "<script>alert(\"your comment has been adding\");</script>";

    }
    }


    ?>
”/>
国家
如果你试图使用一些不好的东西,你的评论将不会插入
代码:
编写这些代码
这是因为,当您刷新页面时,
$\u POST
字段被重置,字段变为空,因此当页面执行其PHP行时,
if($comm\u name=''或$comm\u country=''或$c=''或$POST\u code=''或$POST\u code=''){
它会发现它们是空的。

您需要向我们展示表定义,以便更好地找出问题的确切原因。我猜您的SQL语句没有正确准备。

显然我错过了PHP,因为您现在可以使用
与PHP进行比较。
发生了什么>&&
|
?您可以先对$\u POST['status']、$\u GET['id\u topic']和$\u POST['POST\u code']进行消毒。我知道它们是数字,您可以使用
(int)$\u GET['id\u topic']
处理that@njk,可以同时使用
|
&&
。@coder1984谢谢你提供的信息!好的,我明白了,我应该怎么做来解决这个问题?当我刷新页面时,字段中填充了最后的注释。我如何在MySql中获得表定义?你可以使用他命令“描述”,看这里
    <form action='' method='post' >
    <table  class='rightcol'  width='100%' cellpadding='0' cellspacing='5'>


    <tr>
    <td colspan='3' id='addcomm'>add comm</td>

    </tr>

    <tr>

    <td width='15%' ><div id='title_comm' value=''>name : </div></td>
    <td  ><input type='text' name='comm_name' value='<?if (!$insertcomm){
    echo $comm_name;
    }?>'/></td>
    </tr>

    <tr>
    <td width='15%' ><div id='title_comm'>country  </div></td>
    <td ><input type='text' name='comm_country' 
    value='<?if (!$insertcomm){echo $comm_country;}?>'/>
    </td>
    </tr>


    <tr>
    <td valign='top' width='15%'><div id='title_comm'>comment : </div></td>
    <td width='50%'>
    <textarea  cols='55' rows='12' name='comm'>
    <?if (!$insertcomm){echo $c;}?>
    </textarea></td>
    <td valign='top' ><div id='note_comm'>
  your comment will not insert if you try to use some thing bad
    </div></td>
    </tr>


    <tr>
    <td width='15%' ><div id='title_comm'><span style='color:red'>code : <br/>write these codes </span></div></td>
    <td ><input type='text' name='post_code'/></td>
    </tr>

    <tr>
    <td ><div id='code'>
    <?php 
    $text=rand(400,80000);
    echo $_SESSION['code']=$text;
    ?>


    </div></td>
    </tr>




    <td colspan='4' ><input type='submit' name='addcomm' id='add' value='add comm'/></td>

    </table>
    <input type='hidden' name='comm_thread' value='<?php echo $getidtopic;?>' />
    <input type='hidden' name='add' value='comm'/>
    <input type='hidden' name='status' value='2'/>
    </form>