Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Panggil script koneksi
- require 'connect.php';
- //Ambil data dari form
- $username = $_POST['username'];
- $password = $_POST['password'];
- //Cek data user berdasarkan username
- $query = mysqli_query($conn, "SELECT * FROM user WHERE username = '$username'");
- $jumlah_record = mysqli_num_rows($query);
- if ( $jumlah_record == 1 ) {
- //Ambil data user
- $result = mysqli_fetch_array($query, MYSQLI_ASSOC);
- //Bandingkan password
- if ( password_verify($password, $result['password']) ) {
- echo "Login berhasil!<br>silahkan masuk ke <a href='admin.php'>halaman admin</a>";
- } else {
- die('Password tidak cocok!');
- }
- } else {
- die('Akun yang anda masukkan tidak terdaftar di website kami');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement