嘿傢伙我試圖讓一個PHP腳本檢查文本框是否爲空,我使用下面的代碼。檢查文本框是否爲空?
<?php
$dbname = $_POST['db_name'];
$dbuser = $_POST['db_user'];
$dbpass = $_POST['db_pass'];
$username = $_POST['username'];
$password = $_POST['password'];
if($dbname == "" || $dbuser == "" || $dbpass == "" || $username == "" || $password == "")
{
Echo("Missing Information!");
}else{
Echo("Success!");
}
?>
下面是我的表單代碼: 「缺少信息」
<form method="post" style="padding-left: 50px" action="install_submit.php">
<h2>Database connection settings</h2>
<label for="db_name">Database name:</label>
<input type="textbox" id="db_name" name="db_name" /><br/>
<label for="db_user">Database username:</label>
<input type="textbox" id="db_user" name="db_user" /><br/>
<label for="db_pass">Database password:</label>
<input type="password" id="db_pass" name="db_pass" /><br/>
<h2>CPanel settings</h2>
<label for="username">Username:</label>
<input type="textbox" id="username" name="username" /><br/>
<label for="password">Password:</label>
<input type="password" id="password" name="password" /><br/>
<input type="submit" name="submit_install" value="Install" />
</form>
有了它總是返回即使當所有的文本框都填寫了。
我在做什麼錯?
執行'print_r($ _POST)'來檢查它沒有問題。 – JJJ