Guest User

Untitled

a guest
Apr 2nd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. // i tried echoing everything possible but no outcome
  2. <?php
  3. include("conn.php");
  4. if(isset($_POST['btn_login'])){
  5. $username = $_POST['username'];
  6. $password = $_POST['password'];
  7.  
  8. }
  9. $sql = "SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1";
  10.  
  11. $result = mysqli_query($conn,$sql);
  12.  
  13. $response = array();
  14. if(mysqli_num_rows($result)>0){
  15. $row = mysqli_fetch_row($result);
  16. $username = $row['username'];
  17. $password = $row['password'];
  18.  
  19.  
  20. $code = "login_success";
  21. array_push($response,array("code"=>$code,"username"=>$username,"password"=>$password));
  22. echo json_encode($response);
  23. }
  24. else{
  25. $code = "login_failed";
  26. $message = "User not found... Please try again";
  27. array_push($response, array("code"=>$code,"message"=>$message));
  28. echo json_encode($response);
  29. }
  30. mysqli_close($conn);
  31. ?>
  32. <!DOCTYPE html>
  33. <html>
  34. <head>
  35. <title></title>
  36. </head>
  37. <body>
  38. <form method="post">
  39. <input type="text" name="username">
  40. <input type="text" name="password">
  41. <input type="submit" name="btn_login">
  42. </form>
  43. </body>
  44. </html>
Add Comment
Please, Sign In to add comment