Look at the error message, it gives you a lot of information. It tells you the file it occurs in:
login.php
, it tells you the line it happened on:
66
, and it tells you what it found was wrong:
call to a member function bind_param() on bool
So go to line 66:
$stmt->bind_param("sssss", $fname, $lname, $uname, $email, $pass);
And it calls
bind_param
on
$stmt
HOw can that be wrong? Look at the lines above and see where
$stmt
was loaded with a value:
$stmt = $conn->prepare($sql);
$stmt->bind_param("sssss", $fname, $lname, $uname, $email, $pass);
if($stmt->execute())
Then look at the documentation for the
prepare
method and look at its return code:
PHP: mysqli::prepare - Manual[
^]
Quote:
mysqli_prepare() returns a statement object or false if an error occurred.
Ah! The error said a
bool
was involved, so
prepare
is returning
false
.
Which means that it failed for some reason.
The SQL looks pretty reasonable:
INSERT INTO `users`(`FirstName`, `LastName`, `Username`, `Email`, `Password`) VALUES (?, ?, ?, ?, ?)
So it's possible it's the connection, which we can't test as we have no access to your system.
So start there and look for what is wrong!
You should expect to get errors every day, probably many times a day while you are coding - we all do regardless of how much experience we have! Sometimes, we misspell a variable, or a keyword; sometimes we forget to close a string or a code block. Sometimes the cat walks over your keyboard and types something really weird. Sometimes we just forget how many parameters a method call needs.
We all make mistakes.
And because we all do it, we all have to fix syntax errors - and it's a lot quicker to learn how and fix them yourself than to wait for someone else to fix them for you! So invest a little time in learning how to read error messages, and how to interpret your code as written in the light of what the compiler is telling you is wrong - it really is trying to be helpful!
So read this:
How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[
^] - it should help you next time you get an error!
And ... you need to fix something much deeper than that: Never store passwords in clear text - it is a major security risk. There is some information on how to do it here:
Password Storage: How to do it.[
^]
And remember: if this is web based and you have any European Union users then GDPR applies and that means you need to handle passwords as sensitive data and store them in a safe and secure manner. Text is neither of those and the fines can be .... um ... outstanding. In December 2018 a German company received a relatively low fine of €20,000 for just that.