Postingan lainnya
cara mengatasi errornya gimana ya?
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\login\login.php on line 25
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\login\login.php on line 26
Maaf username dan password anda salah
<?php
session_start();
include "koneksi.php";
?>
<!DOCTYPE html>
<html>
<head>
<title>Halaman Login</title>
</head>
<body>
<form method="post">
<label>Username :</label>
<input type="text" name="fusername"><br>
<label>Password :</label>
<input type="Password" name="fpassword"><br>
<button type="submit" name="fmasuk">Login</button>
</form>
<?php
if (isset($_POST['fmasuk'])) {
$Username = $_POST['fusername'];
$Password = $_POST['fpassword'];
$koneksi=$username=$password='';
$qry = mysqli_query($koneksi,"SELECT * FROM tab_login WHERE Username = '$username' AND Password = md5('$password')");
$cek = mysqli_num_rows($qry);
if ($cek==1) {
$_SESSION['userweb']=$Username;
header ("location:admin.php");
exit;
}
else {
echo "Maaf username dan password anda salah";
}
}
?>
</body>
</html>
Tanggapan
bikin judul sesuai pertanyaan ya, baca aturan main cara bertanya yang baik
2 Jawaban:
<div>Setelah saya coba dan saya buat databasenya,<br>Mungkin Kesalahan nya ada di sini : </div><div><br></div><pre><pre>$qry = mysqli_query($koneksi,"SELECT * FROM tab_login WHERE Username = '$username' AND Password = md5('$password')");</pre></pre><div><br></div><div>Mungkin Seharusnya function md5 itu dihapus saja, dan di buat variabel baru, agar tidak error.<br><br>Ini Kode yang sudah saya perbaiki dan berhasil, tanpa ada error. :<br><br></div><pre> <?php session_start(); include "koneksi.php"; //$koneksi = mysqli_connect("localhost","root","","login"); ?>
<!DOCTYPE html> <html> <head> <title>Halaman Login</title> </head> <body> <form method="post"> <label>Username :</label> <input type="text" name="fusername"><br> <label>Password :</label> <input type="Password" name="fpassword"><br> <button type="submit" name="fmasuk">Login</button> </form>
<?php if (isset($_POST['fmasuk'])) { $username = $_POST['fusername']; $password = $_POST['fpassword']; $passmd5 = md5($_POST['fpassword']); //$koneksi=$username=$password=''; $qry = mysqli_query($koneksi,"SELECT * FROM tab_login WHERE username = '$username' AND password = '$passmd5'"); $cek = mysqli_num_rows($qry); if ($cek == 1) { $_SESSION['userweb'] = $Username; header ("location: admin.php"); exit; } else { echo "Maaf username dan password anda salah"; } } ?> </body> </html></pre><div>Maaf kalau mysqli_connect nya di satu halaman, soalnya tadi saya mau coba.<br>Mungkin kalau error lagi, bisa diganti saja mysqli_connect nya dengan punya saya.<br><br>Semoga Membantu!😁</div>
<div>Terima kasih banyak bang, sudah berhasil kok</div>