Coding Php Untuk Login dan MySQLi Sederhana
Cara Membuat Form Login PHP dan MySQLi Sederhana Tanpa Menggunakan CSS |
1. index.php
2. login.php
[code hl="1, 4, 7"]
<?php
include 'koneksi.php';
$username = $_POST['username'];
$password = $_POST['password'];
$data = mysqli_query($conn,"select * from admin where username='$username' and password='$password'");
// menghitung jumlah data yang ditemukan
$cek = mysqli_num_rows($data);
echo $cek;
?>
<html><body>
<h1>Anda Berhasil Login</h1>
</body>
</html>
[/code]
3. koneksi.php
[code hl="1, 4, 7"]
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "zamalpost";
// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
[/code]
Hasil
Login Sederhana PHP MySQLi | ZamalPost |