I do not want to have to save the double user name and email in MySQL and now this code does not work, what is the problem?
How do I do that?
function isUserExist($email,$userName){
global $connect,$tbl_users;
$email = sanitize($email);
$userName = sanitize($userName);
$sql = ("SELECT `email` FROM `$tbl_users` WHERE `email`=? AND `user_name`=?");
$result = $connect->prepare($sql);
$result->bindValue(1,$email);
$result->bindValue(2,$userName);
$result->execute();
if ($result->rowCount()>=1){
return $result;
}
return false;
}
<?php
$query = null;
$query_exist = null;
if (isset($_POST['btn_submit'])) {
$query_exist = isUserExist($_POST['email'],$_POST['userName']);
if ($query_exist){
echo 'A user with this email has already registered with the site to change your email and try again';
}
else {
$query = createUser($_POST['firstName'], $_POST['lastName'],
$_POST['userName'], $_POST['password'], $_POST['email'],
$_POST['mobile'], $_POST['role']);
}
}