Advertisement
Guest User

Untitled

a guest
Sep 15th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $username = 'admin';
  4. $password = 'admin';
  5. if (isset($_POST['submit'])) {
  6. if ($_POST['username'] == $username && $_POST['password'] == $password){
  7. //Membuat Session
  8. $_SESSION["username"] = $username;
  9. echo "Anda Berhasil Login $username";
  10. /*Jika Ingin Pindah Ke Halaman Lain*/
  11. // header("Location: admin.php"); //Pindahkan Kehalaman Admin
  12. } else {
  13. // Tampilkan Pesan Error
  14. display_login_form();
  15. echo '<p>Username Atau Password Tidak Benar</p>';
  16. }
  17. }
  18. else {
  19. display_login_form();
  20. }
  21. function display_login_form(){ ?>
  22. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method='post'>
  23. <label for="username">username</label>
  24. <input type="text" name="username" id="username">
  25. <label for="password">password</label>
  26. <input type="password" name="password" id="password">
  27. <input type="submit" name="submit" value="submit">
  28. </form>
  29. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement