Postingan lainnya
Isi database tidak sinkron, selalu false
Jadi isi data user yang di database tidak cocok dengan apa yang saya inputkan pada php maupun html, ketika ingin login dengan data yang sudah ada, outputnya selalu flase ini koneksi.php
<?php
$host = "localhost";
$user = "root";
$password = "";
$database = "test";
$connect = mysqli_connect($host, $user, $password, $database)
?>
ini login.php
<form action="login_proses.php" method="post">
<input type="text" name="username" placeholder="username">
<input type="password" name="password" placeholder="password">
<button type="submit" name="submit">Login</button>
</form>
ini login_proses.php
<?php
$username = @mysqli_real_escape_string ($_POST['username']);
$pass = @mysqli_real_escape_string($_POST['password']);
include 'koneksi.php';
$user = mysqli_query($connect,"SELECT * FROM users WHERE username='$username' and password='$pass'");
$chek = mysqli_num_rows($user);
if($chek>0)
{
//header("location:welcome.php");
echo 'hallo';
}else
{
//header("location:login.php");
echo 'yoo';
}
?>
Tanggapan
apakah nama tabel dan nama kolom udh sesuai?
1 Jawaban:
login_proses.php <pre> <?php
include 'koneksi.php';
$username = mysqli_real_escape_string($connect,$_POST['username']); $pass = mysqli_real_escape_string($connect,$_POST['password']);
$user = mysqli_query($connect,"SELECT * FROM users WHERE username='$username' and password='$pass'"); $chek = mysqli_num_rows($user); if($chek>0) { //header("location:welcome.php"); echo 'hallo'; }else { //header("location:login.php"); echo 'yoo'; } ?> </pre>