In my website, I use prepared statement in the login page. It was working fine till last day but now when login using username and password it says "unable to handle the request internal error 500". but its working fine in localhost also. Why this happened. All websites I used prepared statement that hosted in the server have the same problem. And when I remove the prapared statement from code its working fine.
if(isset($_POST['login']))
{
$userid=$_POST['userid'];
$password=$_POST['password'];
$qry="select userid,password from login where userid=? and password=?";
$ex=mysqli_prepare($con,$qry);
mysqli_stmt_bind_param($ex,'ss',$userid,$password);
mysqli_stmt_execute($ex);
$res=mysqli_stmt_get_result($ex);
if(mysqli_num_rows($res)>0)
{
header('location:home.php');
$_SESSION['user']=$userid;
}
}
when I remove the prepared statement and edit the code like this its working fine in server
if(isset($_POST['login']))
{
$userid=$_POST['userid'];
$password=$_POST['password'];
$qry="select userid,password from login where userid='$userid' and password='$password'";
$ex=mysqli_query($con,$qry);
if(mysqli_num_rows($ex)>0)
{
header('location:home.php');
$_SESSION['user']=$userid;
}
}
I got the error message "PHP Fatal error: Call to undefined function mysqli_stmt_get_result()". But my doubt is this code was working fine a few days before. Then how it would get the error now.Please help me to find a solution. My problem is it was well working a few days ago. But now its not working . So the problem is not about code. May be its about hosting. But I have only less knowledge about hosting. So please any one can help me