You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was using the old MySQL to connect and insert and select data from my database and now am changing to mysqli but am getting this problem when I try to insert the register form data to my database
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
and this is the code am using for the form can you please help me defind the error and fix it
i```
f (isset($_POST['submitup'])) {
require '../browser-games/dbh.php';
$username = mysqli_real_escape_string($conn, $_POST['username']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
$Gender = mysqli_real_escape_string($conn, $_POST['Gender']);
$conform = mysqli_real_escape_string($conn, $_POST['conform']);
$email_code = mysqli_real_escape_string($conn,$_POST['username'] + microtime());
$user_date = "3/3/2018";
if(empty($username) || empty($email) || empty($password) || empty($conform)){
$errors[] = "You Left Empty Fields, Fill In All Fields.";
}else{
if (strlen($_POST['password'] < 7)) {
$errors[] = "The Password Should Be At Least 8 Character";
}else{
if($password!==$conform){
$errors[] = "The Password And The Confirm password do not match";
}else{
if (!preg_match("/^[a-zA-Z]*$/",$username)) {
$errors[] = "Only Letters Allowed in The Username";
}else{
if(strlen($_POST['username']) > 30)
{
$errors[] = "The Username can't be more than 30 character";
}else{
if (!empty($_POST)) {
$sql = "SELECT email FROM users WHERE email = ? ";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt,$sql)) {
$errors[] = "fale to connect to the database please try again later";
}else{
mysqli_stmt_bind_param($stmt,"s",$email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$emailcheck = mysqli_num_rows($result);
if($emailcheck>0){
$errors[] = "This Email Already exist In Our Database Please Try a different One, Or Contact Us if you lost your Account At GameHup";
}else{
$sql = "SELECT username FROM users WHERE username = ? ";
mysqli_stmt_bind_param($stmt,"s",$username);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$usernamecheck = mysqli_num_rows($result);
if($usernamecheck>0){
$errors[] = "This UserName Already Registered At GameHup Please Try A Another One";
}else{
//lock the password;
$passhash = password_hash($password , PASSWORD_DEFAULT);
$sql = $conn->prepare("INSERT INTO users (username,password,email,gender,email_code,user_level,user_date)
VALUES(?,?,?,?,?,?,?)");
$stmt->bind_param("sssssss",
$username,$password,$email,$Gender,$email_code,$user_level,$user_date);
$stmt->execute();
function email($to,$subject,$body){
mail($to,$subject,$body, 'From: info@gamehup.com');
}
email(mysqli_real_escape_string($conn,$_POST['email']), 'Activate your Account GameHup', "
Hello ".$_POST['username']." \n\n There's just one more step to go, and it's the easiest one yet. \n\n
Click the link below to confirm your Account \n\n
http://gamehup.com/activate.php?email=".mysqli_real_escape_string($conn,$_POST['email'])."&code=".$email_code."\n\n GameHup Best Free to play browser games ");
$success[] = "You Registered Successfully At GameHup Please check Your Email Inpox For Confirmation Code";
}
}
}
}
}
}
}
}
}
}
The text was updated successfully, but these errors were encountered:
I was using the old MySQL to connect and insert and select data from my database and now am changing to mysqli but am getting this problem when I try to insert the register form data to my database
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
and this is the code am using for the form can you please help me defind the error and fix it
The text was updated successfully, but these errors were encountered: