Git Product home page Git Product logo

gamehup's People

gamehup's Issues

insert data to the database using mysqli

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: [email protected]');
		}
		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";
}
}

        	}
        	}
        }
}
}
}
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.