Just begun to learn php and encounter this problem.: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
Everything is working, my data is saved to database, and i get the message that show, "Registration successful", but i still get that error message.
Error is shown in this line
$stmt->bind_param("ssss", $firstname, $surname, $passwor, $email);
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
$passwor = $_POST['passwor'];
$email = $_POST['email'];
if (!empty($firstname) || !empty($surname) || !empty($passwor) || !empty($email))
{
$host = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "registration";
$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 loginas Where email = ? Limit 1";
$INSERT = "INSERT Into loginas (`firstname`, `surname`, `passwor`, `email`) values('$firstname', '$surname', '$passwor', '$email')";
$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, $surname, $passwor, $email);
$stmt->execute();
echo "Registartion sucesfull";
}
else
{
echo "This email is already in use";
}
$stmt->close();
$conn->close();
}
}
else {
echo "All fields must be filled";
die();
}