<?php
$con = mysqli_connect('localhost','root','[mypassword]','dbhwsource');
if(isset($_GET['username'])){
$username = $con->real_escape_string($_GET['username']);
$test = $con->query("SELECT username FROM users WHERE username='$username'");
if($test!=false) die("usererror");
}
if(isset($_GET['email'])){
$email = $con->real_escape_string($_GET['email']);
$test = $con->query("select * from users where email='$email'");
if($test!=false) die("emailerror");
}
$con->close();
echo "ok";
?>
だから私はユーザー名/電子メールが利用可能かどうかを確認しようとしていますが、入力されたユーザー名が何であっても、私が得るのは「usererror」だけです!私はただイライラしていて、どこでもサンプルコードを検索しましたが、コードには何の問題もないようです。私は何が間違っているのですか?
編集:
$test = $test->fetch_assoc();
if(!empty($test)) die("usererror");
これはうまくいきました!