Advertisement
Guest User

assd

a guest
Jul 12th, 2017
83
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. session_start();
  3. ob_start();
  4. include "../koneksi.php";
  5.  
  6. if (isset($_POST['username']) && isset($_POST['password'])) {
  7. $username = addslashes(htmlspecialchars(mysqli_real_escape_string($con, $_POST['username'])));
  8. $password = addslashes(htmlspecialchars(mysqli_real_escape_string($con, md5($_POST['password']))));
  9. }
  10. else {
  11. die("<h1>Login Dulu >:(</h1>");
  12. }
  13.  
  14. $q = "SELECT * FROM admin WHERE username='$username' AND password='$password'";
  15. $query = mysqli_query($con, $q);
  16. $srow = mysqli_num_rows($query);
  17. $r=mysqli_fetch_array($query);
  18.  
  19. if ($srow > 0) {
  20.  
  21. $_SESSION[level]= $r[level];
  22.  
  23. $_SESSION[username] = $r[username];
  24.  
  25. $_SESSION[password] = $r[password];
  26.  
  27. header('location:index.php');
  28. }
  29. else{
  30. ?><script>alert("U/P salah");document.location.href="index.php"</script> <!--document.location.href="index.php"-->
  31. <?php
  32. }
  33. mysqli_close($con);
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement