This is what that comes up, after I click submit button:
Warning: mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in C:\xampp\htdocs\tonevre\insert.php on line 14 Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in C:\xampp\htdocs\tonevre\insert.php on line 14 Connect Error(2054)The server requested authentication method unknown to the client
This is my INSERT.PHP code:
<?php
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
$password = $_POST['password'];
if (!empty($firstName) || !empty($lastName) || !empty($email) || !empty($password)){
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "database";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$SELECT = "SELECT email From database Where email = ? Limit 1";
$INSERT = "INSERT Into database (firstName, lastName, email, password) values(?, ?, ?, ?)";
// Prepare statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("ssss", $firstName, $lastName, $email, $password);
$stmt->execute();
echo "New record inserted successfully";
} else {
echo "Someone already register using this email";
}
$stmt->close();
$conn->close();
}
} else {
echo "All field are required";
die();
}
?>