0

I have a database named "assignmentdb" and i'm using xampp to do my project. I'm using these codes for my login page for my website. There's an error for line "$stmt->bind_param("s", $userid); "

"Fatal error: Call to a member function bind_param() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/Assignment/loginsuccess.php on line 50"

This is my codes:

$userid = $_POST['userid'];
$password = $_POST['password'];

$mysqli = new mysqli("localhost", "root", null, "assignmentdb");
$stmt = $mysqli->prepare("Select password from forumuser where userid=?");
$stmt->bind_param("s", $userid); 
$stmt->execute();
$stmt->bind_result($p);
$stmt->fetch();
$stmt->close();
$mysqli->close();

if($p == $password){ 
echo '<p>Welcome! You have logged in successfully!</p>';
echo 'Please <a href="comments.html">Click here to continue</a>';
echo "<p><a href='messages(7).php?userid=$userid'>Go To my Messages</a> </p>";
}
else{
    echo '<p><h1>Login unsuccessful!</h1>';
}
Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94

1 Answers1

1

Mmm this seems that $stmt is not initialized, maybe u should check if conection to the database is right. This seems no errors with query.