Advertisement
Guest User

login.php

a guest
Sep 16th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require 'config/connect.php';
  4.  
  5.  
  6. // Jika Pernah Login
  7. if (isset($_SESSION['uid'])) {
  8. header('Location:profile.php');
  9. exit;
  10. }
  11.  
  12. if ($_SERVER['REQUEST_METHOD']=='POST') {
  13. $username=$_POST['username'];
  14. $password=md5($_POST['password']);
  15.  
  16. $login =$config->query("SELECT * FROM user FROM username='$username', password='$password'");
  17. if ($login->num_rows == 1) {
  18. $result =$login->fetch_assoc();
  19. $_SESSION['uid']=$result['id'];
  20.  
  21. header('Location:profile.php');
  22. exit;
  23. }else{
  24. echo "Wah Gagal we, cobain lagi gih";
  25. }
  26. }
  27.  
  28. ?>
  29. <!DOCTYPE html>
  30. <html>
  31. <head>
  32. <title>Login Page</title>
  33. </head>
  34. <body>
  35. <form action="" method="post">
  36. <input type="text" name="username"><input type="password" name="password"><button type="submit">Login</button>
  37. </form>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement