// User's Login
public function Login($username, $pass, $table_name){
$password = SHA1($pass);
if(!empty($username) && !empty($password)){
$user = $this->link->prepare("SELECT * FROM $table_name WHERE username=? AND pass=?");
$user->bind_param("ss", $username, $password);
$user->execute();
$result = $user->get_result();
if($result->num_rows==1){
session_start();
$row=$result->fetch_assoc();
$loginuser = $_SESSION['name']=$row['username'];
$logged_id =$_SESSION['id']=$row['id'];
$phone_id =$_SESSION['phone']=$row['phone'];
$identity =$_SESSION['identity']=$row['id'].$row['phone'];
if(isset($_SESSION['name'])) {
ob_start();
header('Location: dashboard?id='.$row['id'].$row['phone']);
exit();
} else {
echo "<p class='col-sm-4 mx-auto mt-5 alert alert-danger text-center'>Invalid Session, Try Again</p>";
}
}else{
echo "<p class='col-sm-4 mx-auto mt-5 alert alert-danger text-center'>Invalid Username and Password</p>";
}
}else{
echo "<p class='col-sm-4 mx-auto mt-5 alert alert-danger text-center'> Empty Login Details </p>";
}
}
这是处理我的登录表单的功能,它在Xamp上可用,但在实时服务器上显示错误。 致命错误:未捕获错误:调用
中未定义的方法mysqli_stmt :: get_result()答案 0 :(得分:1)
它需要mysqlnd驱动程序...如果未在您的网站空间中安装它,则必须使用BIND_RESULT&FETCH!
extension=php_mysqli_mysqlnd.dll
in php.ini
;并重新启动Apache2
请阅读该方法的用户说明:
http://php.net/manual/en/mysqli-stmt.get-result.php
https://secure.php.net/manual/en/mysqli-stmt.bind-result.php