0

このコードを使用して、ユーザー名または電子メール (どちらもできなかったので両方ではない) が既にデータベースにあるかどうかを確認する方法を知りたいですか?

<?php 

/**
* Register User
*/
if (isset($_POST['register'])) {

$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
$salt = "Not important";
$password_hash = crypt($password, "$2y$". $salt);

if (strlen($username) > 20) {
    echo "Username is too big";
}elseif (strlen($password) > 32) {
    echo "Password is too big";
}elseif (strlen($email) > 100) {
    echo "E-Mail is too big";
}else{
    $sth = $dbh->prepare('SELECT username, email FROM user WHERE username = ? AND email = ?');
    $sth->execute(array($username, $email));
    if ($result = $sth->fetch(PDO::FETCH_OBJ)) {
        print $result->username . "Username and email correct";
    }else{
        echo "Username or email incorrect"; //This is where I want to know how can I check one after another?
    }

}
}else{
echo "Not important";
}


?>

ありがとうございました

4

1 に答える 1