我有這樣的代碼:奇怪的空POST輸出PHP
<?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文件後,這是輸出,當我離開輸入空:
用戶名設置 用戶名是空
密碼設置爲 密碼不爲空
爲什麼?
的name屬性是什麼'的print_r($ _ POST)的;'顯示?編輯,只是看到:「這是我輸入空的時候的輸出」 - >是不是它應該這樣做呢?當你將它們留空時顯示「字段爲空」。 – RelevantUsername 2013-05-07 19:54:32
print_r顯示:[object HTMLInputElement] – jevniky 2013-05-07 20:52:00