如果Gmail不存在,我想将用户添加到数据库,此方法从Android应用程序提供Gmail和密码,您能帮我检查一下吗?
function addUser($gmail, $password){
$connection = mysqli_connect(DataBaseManager::HOST,DataBaseManager::USER,DataBaseManager::PASSWORD,DataBaseManager::DATABASENAME);
mysqli_set_charset($connection, "utf8");
$sqlCommand = "INSERT INTO users(gmail , password )VALUES('$gmail','$password')";
if (mysqli_query($connection, $sqlCommand)) {
return true;
} else {
return false;
}
}
答案 0 :(得分:0)
You can query this to know if a user is already registered.
SELECT gmail
FROM users
WHERE gmail = '$gmail'
If you have 1 row returned, so this user is already registered.
Once you find if this user exists, you can do your query with the INSERT
clause.