Hello,
I tried to verify if users or record already exist in the database so to do that I used a concept of in array fucntion but this was not successfull
here is my code
function adduser($connect) {
$uname = $_POST['uname'];
$pass = $_POST['pass'];
$email = $_POST['email'];
$query_get = mysqli_query($connect, "SELECT * FROM users");
while($row = mysqli_fetch_array($query_get)) {
$username = $row["username"];
}
if(in_array($uname, $username, TRUE)) {
$_SESSION["msg"] = "This user is already registered Please try a different username";
} else {
$query = "INSERT INTO users (username, password, email) VALUES ('$uname', '$pass', '$email')";
$insert = mysqli_query($connect, $query);
if($insert) {
$_SESSION["msg"] = "You have successfully registered";
header("Location: register.php");
exit();
} else {
$_SESSION["msg"] = "There were some errors while registering. Please try again";
header("Location: register.php");
}
}
}
My error
Warning: in_array() expects parameter 2 to be array, string given in /home/....