私はこのコードを持っています:
<?php
if ( isset($_POST['username']) === true){
echo 'Username is set';
if ( $_POST['username'] == "" ){
echo '<br> Username is empty';
} else {
echo '<br>Username is not empty';
}
}
if ( isset($_POST['password']) === true ){
echo 'Password is set';
if ( $_POST['password'] == "" ){
echo '<br> Password is empty';
} else {
echo '<br>Password is not empty';
}
}
?>
そして私はフォームを持っています:
<input type="text" name="username" placeholder="Username" id="username" onKeyUp="javascript:check_username();">
<input type="password" name="password" placeholder="Password" id="password" onKeyUp="javascript:check_password();">
関数は ajax を呼び出してユーザー名/パスをチェックし、php ファイルを実行した後、入力を空のままにした場合の出力は次のようになります。
ユーザー名が設定されています ユーザー名が空です
パスワードが設定されています パスワードは空ではありません
何故ですか??