I know this question has been asked many times, and I have looked, followed instructions from suggestions, and have come up with zero solutions.
- Check to see if I had a different number of columns in my table vs my code/ No issues there
- Checked spelling on all columns and make sure they match/ No issues there
- Check columns and make sure they are in the same order/ No issues there
- Check to make sure database is connected/ No issues there
- Make sure that your id is listed as NULL/ No issues there
Kinda lost on this one, so I'm reaching out.
Heres my code:
DbOperations.php
    <?php
    class DbOperations{
        private $con;
        function __construct(){
            require_once dirname(__FILE__).'/DbConnect.php';
            $db = new DbConnect();
            $this->con = $db->connect();
        }
        /*CRUD -> C -> CREATE */
        public function createUser($firstname, $lastname, $usercountry, $userphone, $useremail, $userpassword){
            if($this->isUserExist($useremail)){
                return 0;
            }else{
                $password = md5($userpassword);
    //This is where the error is occurring          
$stmt = $this->con->prepare("INSERT INTO `users` (`id`, `firstName`, `lastName`, `userCountry`, `userPhone`, `userEmail`, 'userPassword') VALUES (NULL, ?, ?, ?, ?, ?, ?);");
                $stmt->bind_param("ssssss", $firstname, $lastname, $usercountry, $userphone, $useremail, $password);
                if($stmt->execute()){
                    return 1;
                }else{
                    return 2;
                }
            }
        }
        public function userLogin($useremail, $userpassword){
            $password = md5($userpassword);
            $stmt = $this->con->prepare("SELECT id FROM users WHERE userEmail = ? AND userPassword = ?");
            $stmt->bind_param("ss",$username,$password);
            $stmt->execute();
            $stmt->store_result();
            return $stmt->num_rows > 0;
        }
        public function getUserByEmail($useremail){
            $stmt = $this->con->prepare("SELECT * FROM users WHERE userEmail = ?");
            $stmt->bind_param("s",$username);
            $stmt->execute();
            return $stmt->get_result()->fetch_assoc();
        }
        private function isUserExist($useremail){
            $stmt = $this->con->prepare("SELECT id FROM users WHERE userEmail = ?");
            $stmt->bind_param("s", $useremail);
            $stmt->execute();
            $stmt->store_result();
            return $stmt->num_rows > 0;
        }
    }
  ?>
registerUser.php
<?php
require_once 'DbOperations.php';
$response = array();
if($_SERVER['REQUEST_METHOD']=='POST'){
    if(
        isset($_POST['firstName']) and
            isset($_POST['lastName']) and
                isset($_POST['userCountry']) and
                isset($_POST['userPhone']) and
                    isset($_POST['userEmail']) and
                        isset($_POST['userPassword']))
        {
        //operate the data further
        $db = new DbOperations();
        $result = $db->createUser(  $_POST['firstName'],
                                    $_POST['lastName'],
                                    $_POST['userCountry'],
                                    $_POST['userPhone'],
                                    $_POST['userEmail'],
                                    $_POST['userPassword']
                                );
        if($result == 1){
            $response['error'] = false;
            $response['message'] = "User registered successfully";
        }elseif($result == 2){
            $response['error'] = true;
            $response['message'] = "Some error occurred please try again";
        }elseif($result == 0){
            $response['error'] = true;
            $response['message'] = "It seems you are already registered, please choose a different email and username";
        }
    }else{
        $response['error'] = true;
        $response['message'] = "Required fields are missing";
    }
}else{
    $response['error'] = true;
    $response['message'] = "Invalid Request";
}
echo json_encode($response);
I appreciate all the help in advance!
