我需要檢查用戶輸入的用戶名和密碼是否正確,以便登錄。如果正確,它將運行javascript代碼中的一行代碼,如果沒有它只會提醒用戶名/密碼錯誤。問題是,該頁面只是刷新,它不運行的JavaScript代碼,即使用戶名&密碼是正確的,這也顯示:無法檢查我的登錄信息
警告:mysqli_num_rows()預計參數1被mysqli_result, 布爾在d給出:上線\ XAMPP \ htdocs中\統計\的index.php 195
(上述錯誤是固定的,現在不工作的只有一個是javascript代碼)
這裏是我的PHP代碼爲登錄:
if(isset($_POST['proceedToLogin'])) {
if((!empty($_POST['username'])) && (!empty($_POST['password']))) {
$uname = $_POST['username'];
$pword = $_POST['password'];
$selup = "SELECT * admin WHERE Username ='$uname'AND Password ='$pword'";
$checkup = mysqli_query($conn, $selup);
if(mysqli_num_rows($checkup) > 0) {
print '<script type="text/javascript">';
print 'goHome(1);';
print 'return false;';
print '</script>';
}
}
}
這是應該運行的JavaScript代碼:
function goHome(source){
$('#bluearrow').css('margin-left','-100px');
$('#orangearrow').css('margin-left','-200px');
$('#greenarrow').css('margin-left','-300px');
$('#grayarrow').css('margin-left','-400px');
$("body").css("overflow","hidden");
if(source == 1)
$('#login').animate({ opacity: 'hide', left: '-200px', }, 'slow', 'linear', function() {
document.getElementById('username').value ="";
document.getElementById('password').value ="";
$("#login").hide();
$("#login").css('margin-left', '280px');
});
else if(source == 2)
$('#addApplicant').animate({ opacity: 'hide', left: '-200px', }, 'slow', 'linear', function() {
$(this).hide();
$(this).css('left','30px');
});
$("#menu").hide().show();
$("#bluearrow").hide();
$("#orangearrow").hide();
$("#greenarrow").hide();
$("#grayarrow").hide();
$(".menu-label").hide();
$('html,body').scrollTop(0);
setTimeout(function(){
$("#bluearrow").hide().show("slide", { direction: "left" }, 1500);
},500);
setTimeout(function(){
$("#orangearrow").hide().show("slide", { direction: "left" }, 1500);
},1300);
setTimeout(function(){
$("#greenarrow").hide().show("slide", { direction: "left" }, 1500);
},2000);
setTimeout(function(){
$("#grayarrow").hide().show("slide", { direction: "left" }, 1500);
},2700);
setTimeout(function(){
$('span').animate({ opacity: 'show', left: '50px', }, 'slow', 'linear', function() {
$(this).show();
});
},4100);
}
他們都在同一個文件,順便說一句。
我會建議使用庫MySQLi,準備發言,否則我要登錄爲''; DROP TABLE *;'';) – timmyRS