Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2. if(isset($_GET['log'])){
  3. session_start();
  4. session_destroy();
  5. }
  6. $conn = mysqli_connect( "localhost","root","","mydb");
  7. $username = isset($_POST["username"]) ? $_POST["username"] : '';
  8. $password = isset($_POST["password"]) ? $_POST["password"] : '';
  9. $password = md5($password);
  10.  
  11.  
  12.  
  13. if($username!='' and $password!=''){
  14.  
  15. $sql = mysqli_query($conn, "SELECT * from user WHERE username = '$username' AND password = '$password' limit 1");
  16. $data = mysqli_fetch_assoc($sql);
  17.  
  18. if($data){
  19. session_start();
  20. $_SESSION['username'] = $data['username'];
  21. $_SESSION['password'] = $data['password'];
  22. }
  23.  
  24. if(isset($_SESSION["username"])){
  25. header('Location: index.php');
  26. }
  27.  
  28. else {
  29. echo "<script type='text/javascript'>
  30. alert('Gagal login. periksa username dan password anda..!!!');
  31. </script>";
  32. }
  33. }
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement