Postingan lainnya
cara menghubungkan nya gimana ya ?
saya sudah buat username dan password admin nya, tapi saat di jalankan di web tetap ngak mau
per1.PNG
mohon bantuannya ka :pray:
script(login):
<?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>
script(admin):
<!DOCTYPE html>
<html>
<head>
<title>Halaman Admin</title>
</head>
<body>
INI HALAMAN ADMIN <a href="logout.php">keluar</a>
</body>
</html>
1 Jawaban:
<div>Cara cek terhubung atau tidak :</div><pre><?php //koneksi ke database mysql, silahkan di rubah dengan koneksi sendiri $koneksi = mysqli_connect("localhost","root","","nama_database");
//cek jika koneksi ke mysql gagal, maka akan tampil pesan berikut if (mysqli_connect_errno()){ echo "Error melakukan koneksi ke MySQLI: " . mysqli_connect_error(); } ?></pre>