准备好的用户名验证声明

时间:2017-12-09 15:33:53

标签: php mysqli

我需要检查mysql数据库中的用户名是否存在usernsme。下面是我的PHP代码。当我输入用户名时,会显示Fatal error: Call to a member function bind_param() on boolean in ...

这是php代码:

<?php
if (isset($_POST['submit'])) {

               $mobile = $_POST['mobile'];

                $sql = 'SELECT `mobile_message` 
                        WHERE `mobile` = ?';


                // Prepare the SQL statement for execution.
                $statement = $connection->prepare($sql);

                $bound = $statement->bind_param('s', $mobile);

                // Execute the prepared statement.
                $statement->execute();
                $statement->store_result();
                if($statement->num_rows > 0) {


                $_SESSION['e']="This username is already exist. Please try different.";
                header('location:sign.php');
                exit;
        } 
    }

?>

0 个答案:

没有答案