Advertisement
Guest User

Untitled

a guest
Aug 21st, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2. // Turn off all error reporting
  3. error_reporting(0);
  4. ?>
  5. <?php
  6. ob_start();
  7.  
  8. header('Content-type:application/json');
  9. header('Access-Control-Allow-Origin: *');
  10.  
  11. ob_end_flush();
  12.  
  13. $servername = "localhost";
  14. $username = "root";
  15. $password = "asd123ftw";
  16. $dbname = "lin2db";
  17.  
  18. $postdata1='';
  19. $postdata = file_get_contents("php://input");
  20. $request = json_decode($postdata);
  21.  
  22. $user = $request->user;
  23. $pass = $request->pass;
  24. $pass2 = $request->pass2;
  25.  
  26. $conn = new mysqli($servername, $username, $password, $dbname);
  27.  
  28.  
  29.  
  30. $result = mysqli_query($conn, "SELECT login FROM accounts WHERE password='$pass' AND login='$user' ");
  31.  
  32.  
  33. while($row = mysqli_fetch_assoc($result)){
  34. $test[] = $row;
  35. }
  36.  
  37. $test1=mysqli_num_rows($result);
  38.  
  39. if($test1>0){
  40.  
  41. mysqli_query($conn, "UPDATE accounts SET password='$pass2' WHERE login='$user' ");
  42.  
  43. $postdata1= Array(
  44. 'status' => 'The password has been successfully changed.'
  45. );
  46.  
  47. }
  48. else {
  49.  
  50. $postdata1= Array(
  51. 'status' => 'The user does not exist or the password is not correct.'
  52. );
  53.  
  54. }
  55.  
  56. echo json_encode($postdata1);
  57.  
  58. $conn->close();
  59.  
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement