Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('../config.php');
- include('../opendb.php');
- require_once '../functions/security.php';
- $mysqli->query("set names utf8");
- $username = $_POST['username'];
- $pw_old = encrypt($_POST['oldPw']);
- $pw_new = encrypt($_POST['newPw']);
- $response = array();
- if ($username == '' || $pw_old == '' || $pw_new == '') {
- $response['fields'] = 0;
- } else {
- $response['fields'] = 1;
- $qry = "select password from member where username='$username'";
- $result = $mysqli->query($qry);
- $row = $result->fetch_assoc();
- if (strcmp(substr($pw_old, 0, -8), $row['password']) == 0) {
- $response['exist'] = 1;
- $qry = "update member set password='$pw_new' where username='$username'";
- if ($mysqli->query($qry)) {
- $response['success'] = 1;
- } else {
- $response['success'] = 0;
- }
- } else {
- $response['exist'] = 0;
- }
- }
- echo json_encode($response);
- include('../closedb.php')
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement