Advertisement
Guest User

login

a guest
Sep 20th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <?php
  2. require 'db_config.php';
  3. require 'functions.php';
  4.  
  5. if(isset($_POST['username']) && isset($_POST['password'])){
  6.  
  7. $username = $_POST['username'];
  8. $password = $_POST['password'];
  9.  
  10. $password2 = 'salt' .$password;
  11. $password1 = md5($password2);
  12.  
  13. if(!empty($username) && !empty($password1)){
  14. $username = mysqli_real_escape_string($conn,$username);
  15. $password = mysqli_real_escape_string($conn,$password1);
  16.  
  17. $query = "SELECT `username` FROM player WHERE `username`='$username' AND `password`='$password'";
  18. $result = mysqli_query($conn,$query);
  19.  
  20. if(mysqli_num_rows($result) == 0){
  21. echo create_json_response('unsuccessful','Wrong combination of username and password');
  22. }elseif (mysqli_num_rows($result) == 1){
  23. echo create_json_response('successful',$username);
  24. }else echo create_json_response('unsuccessful','Enter username and password');
  25. }else echo create_json_response('unsuccessful','Enter username and password');
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement