我試圖做一個PHP,MySQL登錄腳本。當我輸入錯誤的用戶名或密碼或登錄ID時,它不顯示我的錯誤消息。爲什麼?php mysql,登錄腳本。我的錯誤消息不顯示
$con = mysqli_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno()) {
die ('Failed to connect to MySQL: ' . mysqli_connect_error());
}
$c_id = $_POST['c_id'];
$p_nickname = $_POST['p_nickname'];
$p_password = $_POST['p_password'];
if(!empty($c_id)&&!empty($p_nickname)&&!empty($p_password)){
$query = "SELECT c_id, p_nickname, p_password FROM people_inside_company INNER JOIN company ON pic_c_id = c_id INNER JOIN people ON pic_code_number = p_code_number WHERE c_id = '$c_id' AND p_nickname = '$p_nickname' AND p_password = '$p_password'";
#t
if($result = mysqli_query($con, $query)or die(mysqli_error($con))){
if($row = mysqli_fetch_assoc($result)){
$in_cid = $row['c_id'];
$in_pnickname = $row['p_nickname'];
$in_ppassword = $row['p_password'];
$count = mysqli_num_rows($result);
if($count == 1){
echo "you're in";
# i get this when i type the right c_id, p_nickname and p_passowrd
#more code
}
else{
echo "wrong username, password or id";
# i don't get this when im typing the wrong c_id, p_nickname or p_password, why?
}
}
}
}
因此,你總是打印'你在'? – Akshay
如果我寫了正確的暱稱和密碼和c_id是,如果我typ錯了,它不會顯示任何東西, – Avoka94
使用參數化查詢並散列您的用戶密碼。 – chris85