0
如何讓所有用戶在使用PHP和MySQL提交表單時不需要輸入用戶名就可以使用戶名字段爲空?PHP和MySQL表單問題
這裏是我的PHP和MySQL代碼的一部分。
$username = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['username']))));
if(isset($_POST['username'])) {
// Make sure the username address is available:
$u = "SELECT *
FROM users
WHERE username = '$username'
AND user_id <> '$user_id'";
$r = mysqli_query ($mysqli, $u) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($mysqli));
if (mysqli_num_rows($r) == TRUE) { // Unavailable.
echo '<p class="error">Your username is unavailable!</p>';
$username = NULL;
} else if(mysqli_num_rows($r) == 0) { // Available.
$username = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['username']))));
}
}
的可能重複http://stackoverflow.com/questions/2650043/php-mysql-username-submit-問題 – 2010-04-16 03:03:59
我可能做過嗎? – peakUC 2010-04-16 03:04:59
請重新短語的問題....你問的是不是很清楚... – SpikETidE 2010-04-16 04:05:02