Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Turn off all error reporting
- error_reporting(0);
- ?>
- <?php
- ob_start();
- header('Content-type:application/json');
- header('Access-Control-Allow-Origin: *');
- ob_end_flush();
- $servername = "localhost";
- $username = "root";
- $password = "asd123ftw";
- $dbname = "lin2db";
- $postdata1='';
- $postdata = file_get_contents("php://input");
- $request = json_decode($postdata);
- $user = $request->user;
- $pass = $request->pass;
- $pass2 = $request->pass2;
- $conn = new mysqli($servername, $username, $password, $dbname);
- $result = mysqli_query($conn, "SELECT login FROM accounts WHERE password='$pass' AND login='$user' ");
- while($row = mysqli_fetch_assoc($result)){
- $test[] = $row;
- }
- $test1=mysqli_num_rows($result);
- if($test1>0){
- mysqli_query($conn, "UPDATE accounts SET password='$pass2' WHERE login='$user' ");
- $postdata1= Array(
- 'status' => 'The password has been successfully changed.'
- );
- }
- else {
- $postdata1= Array(
- 'status' => 'The user does not exist or the password is not correct.'
- );
- }
- echo json_encode($postdata1);
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement