Advertisement
Guest User

md5 error

a guest
Apr 3rd, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. include "koneksi/koneksi.php";
  3. session_start();
  4.  
  5. // untuk mencegah sql injection
  6. function anti_injection($data){
  7. $filter=mysql_real_escape_string( stripslashes ( strip_tags ( htmlspecialchars($data, ENT_QUOTES))));
  8. return $filter;
  9. }
  10. $username = anti_injection($_POST['username']);
  11. $password = anti_injection(md5($_POST['password']));
  12.  
  13. //pastikan username dan password berupa huruf atau angka
  14. $cek = mysql_query("SELECT * FROM siswa WHERE username='$username' and password='$password'");
  15. $id = mysql_fetch_array($cek);
  16. if(mysql_num_rows($cek)>=1){
  17. @$_SESSION['username'] = $id['username'];
  18. @$_SESSION['password'] = $id['password'];
  19. header('location: user');
  20. }else{
  21. echo "<script>alert('Username atau password salah!'); document.location.href=\"index.php\"</script>";
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement