Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
195
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. if($_POST[login]){
  3. $error='';
  4. $username = strip_tags($_POST['username']);
  5. $password = md5(strip_tags($_POST['password']));
  6. $ip = $_SERVER['REMOTE_ADDR'];
  7. if(!$username || !$password){
  8. $error.= 'All fields are requred.<br>';
  9. }else{
  10. $check = mysql_query("SELECT * FROM users WHERE `username` = '$username'");
  11. if(mysql_num_rows($check) == 0){
  12. $error.= 'The user <strong>'.$username.'</strong> does not exist.<br>';
  13. }else{
  14. $r = mysql_fetch_array($check);
  15. if($r["banned"] == '1'){
  16. $error.= 'You are currently banned, you can not log in.<br>';
  17. }else{
  18. if($r["password"] !== $password){
  19. $error.= 'The password you entered is incorrect.<br>';
  20. }else{
  21. setcookie("id", $r["id"], time()+(60*60*60*24*5));
  22. setcookie("password", $r["password"], time()+(60*60*60*24*5));
  23. setcookie("sec", md5($ip), time()+(60*60*60*24*5));
  24. mysql_query("UPDATE `users` SET `ip` = '$ip' WHERE `username` = '$username'");
  25. header("Location: index.php");
  26. }
  27. }
  28. }
  29. }
  30. }
  31. if($error){
  32. echo $error;
  33. }
  34. echo '<form method="post">
  35. <input type="text" class="custom" name="username" value="username..." />
  36. <input type="password" class="custom" name="password" value="password" />
  37. <a href="register.php">Register</a> | <a href="forgotpass.php">Forgot Password?</a>
  38. <input type="submit" class="buttom" value="login" name="login" style="float: right" />
  39. </form>';
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement