0

I'm creating a Login and Register Form that sends data into the database.

I'm getting an error which states

Fatal error: Uncaught Error: Call to a member function bind_param() on bool in E:\xampp\htdocs\Website\Login\insert.php:12 Stack trace: #0 {main} thrown in E:\xampp\htdocs\Website\Login\insert.php on line 12

Here's the code

<?php
    $Username = $_POST['Username'];
    $password = $_POST['Password'];

    // Database connection
    $conn = new mysqli('localhost','root','Dec@2007','loginsystem');
    if($conn->connect_error){
        echo "$conn->connect_error";
        die("Connection Failed : ". $conn->connect_error);
    } else {
        $stmt = $conn->prepare("insert into users(Username, Password) values(?, ?, ?)");
        $stmt->bind_param("ss", $Username, $Password);
        $execval = $stmt->execute();
        echo $execval;
        echo "Registration successfully...";
        $stmt->close();
        $conn->close();
    }

I'm pretty sure the problem is not with HTML.

Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

-1

The prepare() returns false when you have error in your query.

Check if the table or columns name are correct.

$stmt = $this->con->prepare("INSERT INTO table(name, quantity) VALUES (?,?)");

Use Capital INSERT INTO this should not be the issue though but you can try.

dev_mustafa
  • 1,042
  • 1
  • 4
  • 14
  • Please don't post answers only pointing out a typographical issue or a missing character. Such answers are unlikely to help future visitors since they are specific to OP's code. Instead, flag or vote to close the question as off-topic as per the [help/on-topic]. – Dharman Jan 28 '21 at 23:23