Hi i am trying to check for the uniqueness of username in a page, but whenever i am running my code it either gives error or a warning message of Warning: Array to string conversion in C:xampphtdocslogin pcprocess_Signup.php on line 22
Code for my php is as follows:
$mysqli = require __DIR__."/database.php";
$sql = "INSERT INTO user_info (uname,pass,email)
VALUES (?,?,?)";
$stmt=$mysqli->stmt_init();
if(! $stmt->prepare($sql)){
echo("SQL error: " . $mysqli->error);
}
$sql1= "SELECT 1 FROM user_info (uname, pass, email) WHERE uname=$_POST('uname')";
$sql2= "SELECT 1 FROM user_info (uname, pass, email) WHERE email=$_POST('email')";
if($sql1>=1){
echo "User Exists!";
}elif($mysql2>=1){
print_r("Email Exists"); # in this line also i get an error i.e., i can not put ';' here
}
else{
$stmt->bind_param("sss",
$_POST["uname"],
$_POST["password"],
$_POST["email"]);
if($stmt->execute())
echo "SignUp Successfull";
}
$result=$stmt->get_result();
The name of the database is login_cred and the name of the table is user_info, can anyone please tell how to remove this error/ warning sign.
The field names in the user_info table are id, uname, pass, email where id is primary key, uname and email are unique.
I would be highly grateful for your help.