PHP不处理某些表单字段

我最近创建了一个PHP / MySQL评论系统,它直到几个小时前都在运行(代码中根本没有任何改变)。 当我告诉提交表单代码以回显查询时,它显示缺少用于评论文本和日期的区域。 我不明白为什么。 这是我的代码:

mysql_connect("localhost","commentUser","password");
mysql_select_db("comments");
$name = mysql_real_escape_string($_POST['name']);
$postID = mysql_real_escape_string($_POST['postId']);
if(!is_numeric($postID))
    exit();
$email = mysql_real_escape_string($_POST['email']);
$comment = strip_tags(mysql_real_escape_string($_POST['comment']), '');
$date = mysql_real_escape_string($_POST['date']);

if($email == '' || $comment = '' || $date = '')
    exit();

$query = "INSERT INTO comments (PostID,Name,Email,Text,Date) VALUES($postID, '$name', '$email', '$comment', '$date')";
mysql_query($query) or die(mysql_error());
mysql_close();

    echo "
        
            window.location = "snippet.php?id=$postID";
        
    ";


您将空字符串分配给$comment ,将$date分配给=

if($email == '' || $comment = '' || $date = '')
    exit();

// Should use `==` for all three:
if($email == '' || $comment == '' || $date == '')
    exit();
链接地址: http://www.djcxy.com/p/21883.html

上一篇: PHP isn't processing some form fields

下一篇: converting text to int from a form