Guest User

Untitled

a guest
Oct 15th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2. $myusername = $_POST['username'];
  3. $mypassword = $_POST['pass'];
  4.  
  5. include("koneksi/koneksi.php");
  6.  
  7. //proteksi dari SQL injection
  8. $myusernamex = stripslashes($myusername);
  9. $mypasswordx = stripslashes($mypassword);
  10. $usernametrue = mysql_real_escape_string($myusernamex);
  11. $passwordtrue = mysql_real_escape_string($mypasswordx);
  12.  
  13. $sql = "select * from user_app where username = '$usernametrue' and pass = '$passwordtrue'";
  14. $result = mysql_query($sql);
  15.  
  16. //menghitung jumlah baris
  17. $count = mysql_num_rows($result); //bila cocok maka nilainya 1
  18.  
  19. if($count == 1){
  20. //register $myusername, $mypassword dan redirect ke file web.php
  21. session_register("myusername");
  22. session_register("mypassword");
  23. header("location: index.php");
  24. exit;
  25. } else {
  26. header('refresh: 3; url=./login.php');
  27. echo "Maaf, Password dan username anda salah";
  28. exit ;
  29. }
  30. ob_end_flush();
  31. ?>
Add Comment
Please, Sign In to add comment