ユーザーが入力したユーザー名とパスワードが正しいため、ログインできるかどうかチェックする必要があります。正しい場合は、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