我正在注册,我想检查是否使用了用户名,不知道为什么要使用mysql_num_rows();函数不会发布任何内容

<?php
if(isset($_POST['name_signup'])) {
    if($_POST['pass_signup']==$_POST['pass_a_signup']){
        $select=mysql_num_rows(mysql_query("SELECT * FROM users WHERE nick='".$_POST['nick_signup']."'"));
        if($select=!0){
        $name=$_POST['name_signup'];
        $secondname=$_POST['secondname_signup'];
        $nick=$_POST['nick_signup'];
        $pass=$_POST['pass_signup'];
        $mail=$_POST['email_signup'];
        $passx=md5(md5($pass));
        include 'db.php';
        mysql_query("INSERT INTO users(firstname,secondname,nick,pass,email,date)VALUE('".$name."','".$secondname."','".$nick."','".$passx."','".$mail."',NOW())");
        echo "Succesfully Signed up";
        echo'<meta http-equiv="refresh" content="3;URL=../index.php">';
        }else {
            echo "Username used";
            echo'<meta http-equiv="refresh" content="3;URL=../index.php?page=signup">';
            }
    }
    else{
        echo'Passwords do not match';
        echo'<meta http-equiv="refresh" content="1;URL=../index.php?page=signup">';
        }
}

else {
    echo'<meta http-equiv="refresh" content="0;URL=../index.php">';
}
?>

最佳答案

mysql扩展名已弃用,您应该停止使用它。而是尝试mysqliPDO

您的代码中存在一个错误:

if($select=!0){


您应该像这样纠正它:

if($select!=0){


同样,停止使用mysql。并开始使用准备好的语句,否则您的代码将面临SQL注入的危险

关于php - mysql_num_rows();不会发布,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36792970/

10-11 05:54