Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2. include "config/koneksi.php";
  3. $con=mysqli_connect("localhost","root","rootroot","ecom");
  4. if (isset($_POST['submit'])){
  5. function cek_form($cek){
  6. $filter = mysqli_real_escape_string($cek);
  7. return $filter;
  8. }
  9.  
  10. $txtuser = mysqli_real_escape_string($con, $_POST['username']);
  11. $txtpass = mysqli_real_escape_string($con, md5($_POST['password']));
  12.  
  13. if (empty($txtpass) || empty($txtuser)){
  14. echo "<script>alert('Username dan Password TIDAK BOLEH KOSONG!');</script>";
  15. }
  16. else{//cek alfabet
  17. if (!ctype_alnum($txtuser) OR !ctype_alnum($txtpass)){
  18. echo "<script>alert('Anda memasukan karakter yang salah');location='index.php?ref=login'</script>";
  19. }
  20. else{
  21. $login=mysqli_query($con, "select * from anggota where username='$txtuser' and password='$txtpass' ");
  22. $ketemu=mysqli_num_rows($login);
  23. $tampil=mysqli_fetch_array($login);
  24.  
  25. //ada user
  26. if ($ketemu > 0){
  27. session_start();
  28.  
  29. //daftar session
  30. //session_register("id_anggota");
  31. $_SESSION["id_anggota"] = $ketemu;
  32.  
  33. //isi session
  34. $_SESSION['id_anggota']=$tampil['id_anggota'];
  35.  
  36. echo"<meta http-equiv='refresh' content='0; url=index.php'>";
  37. }
  38. else{
  39. echo "<script>alert('Username atau Password Salah!');</script>";
  40. }
  41. }
  42. }
  43. }
  44. else{
  45. echo"<meta http-equiv='refresh' content='0; url=index.php'>";
  46. }
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement