Advertisement
Guest User

Untitled

a guest
Nov 17th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2. include('../config.php');
  3. include('../opendb.php');
  4.  
  5. require_once '../functions/security.php';
  6.  
  7. $mysqli->query("set names utf8");
  8.  
  9. $username = $_POST['username'];
  10. $pw_old = encrypt($_POST['oldPw']);
  11. $pw_new = encrypt($_POST['newPw']);
  12.  
  13. $response = array();
  14.  
  15. if ($username == '' || $pw_old == '' || $pw_new == '') {
  16. $response['fields'] = 0;
  17. } else {
  18. $response['fields'] = 1;
  19. $qry = "select password from member where username='$username'";
  20. $result = $mysqli->query($qry);
  21. $row = $result->fetch_assoc();
  22. if (strcmp(substr($pw_old, 0, -8), $row['password']) == 0) {
  23. $response['exist'] = 1;
  24. $qry = "update member set password='$pw_new' where username='$username'";
  25. if ($mysqli->query($qry)) {
  26. $response['success'] = 1;
  27. } else {
  28. $response['success'] = 0;
  29. }
  30. } else {
  31. $response['exist'] = 0;
  32. }
  33. }
  34.  
  35. echo json_encode($response);
  36. include('../closedb.php')
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement