php - Why Won't My Register/Login Forms Check/Update Database


The problem is that my register and login server-side validation doesn't work. The client-side validation still works to check if fields are filled out the way I want them to be.

The submit button also use to work, but no longer does. Instead you click it and there is an error on the server side validation that causes it not to submit.

Here is My Login Form HTML:

Here is My Login Form JS:

Here is My Login Form PHP:

    include 'dbconfig.php';

    $loginUsername = $loginPassword = "";

    if ($_SERVER['REQUEST_METHOD'] == "POST"){
        $loginUsername = test_input($_POST['l_username']);
        $loginPassword = test_input($_POST['l_password']);

    function test_input($data){
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        return $data;

    $loginHashed = hash('sha512', $loginPassword);  //CHAR 128 - length field

    $stmt = $conn->prepare("SELECT * FROM users WHERE username = ? && password = ?");
    $stmt->bind_param("ss", $loginUsername, $loginHashed);

    $result = $stmt->get_result();
    if($result->num_rows == 1){
        echo 'ok';
        echo "Invalid Username and/or Password";



It connects to the database fine as i can tell from thedbconfig.php file. I'm not exactly sure where it goes wrong. The only error I ever saw was something like:

PHP Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::get_result()

However, I don't know why this would occur as I can't seem to get it to work on both my web server and a fresh most up-to-date version ofMAMP.

I have tried my friend's website code as well as my teacher's working website code on my web server/MAMP and both seem to have the same issue where when you click the submit button on both the login and register forms it sits there doesn't do anything and doesn't update the database with a new user.

People are also looking for solutions to the problem: PHP Fatal error: Interface 'PsrHttpMessageRequestInterface' not found | Laravel 5.6.4


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.