Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. function ambil_ip() {
  6. foreach (array('HTTP_CLIENT_IP', 'HTTP_X_REAL_IP', 'REMOTE_ADDR', 'HTTP_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED') as $key); {
  7. if (array_key_exists($key, $_SERVER) === true); {
  8. foreach (explode(',', $_SERVER[$key]) as $ip); {
  9. if (filter_var($ip, FILTER_VALIDATE_IP) !== false); {
  10. return $ip;
  11. }
  12. }
  13. }
  14. }
  15. }
  16.  
  17. include'../config.php';
  18.  
  19.  
  20. if(!empty($_POST['pass'])) {
  21. if(!empty($_POST['mail'])) {
  22. $username = $_POST['mail'];
  23. $username = mysql_real_escape_string($username);
  24. $pass = $_POST['pass'];
  25. $pass = $pass;
  26. $cekuser = mysql_query("SELECT * FROM user WHERE email = '$username'");
  27. $jumlah = mysql_num_rows($cekuser);
  28. $hasil = mysql_fetch_array($cekuser);
  29. $ip = ambil_ip();
  30.  
  31. if($jumlah == 0) {
  32. header('location: /account/?msgr=Ups!! Email '.$username.' no esta registrado!!');
  33. } else if($pass != $hasil['password']){
  34. header('location: /account/?msgr=Ups!! La contraseña que ingresó es incorrecta!');
  35. } else {
  36. $username = $_SESSION['email'];
  37. $k = mysql_query("UPDATE `user` SET `ip`='$ip' WHERE email = '$username'");
  38. header('location: /');
  39. }
  40. } else {
  41. header('location: /account/?msgr=Ups!! El campo de Email esta vacio!');
  42. }
  43. } else {
  44. header('location: /account/?msgr=Ups!! El campo de la contraseña esta vacio!');
  45. }
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement