Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $username = 'admin';
- $password = 'admin';
- if (isset($_POST['submit'])) {
- if ($_POST['username'] == $username && $_POST['password'] == $password){
- //Membuat Session
- $_SESSION["username"] = $username;
- echo "Anda Berhasil Login $username";
- /*Jika Ingin Pindah Ke Halaman Lain*/
- // header("Location: admin.php"); //Pindahkan Kehalaman Admin
- } else {
- // Tampilkan Pesan Error
- display_login_form();
- echo '<p>Username Atau Password Tidak Benar</p>';
- }
- }
- else {
- display_login_form();
- }
- function display_login_form(){ ?>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method='post'>
- <label for="username">username</label>
- <input type="text" name="username" id="username">
- <label for="password">password</label>
- <input type="password" name="password" id="password">
- <input type="submit" name="submit" value="submit">
- </form>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement