Advertisement
alatoru

change.php

Mar 19th, 2023
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.00 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['login'])
  3.     && isset($_POST['old_pswd'])
  4.         && isset($_POST['change_pswd'])
  5.             && isset($_POST['change_pswd_sec']))
  6.     {  
  7.  
  8.         $login = $_POST['login'];
  9.         $login = stripslashes($login);
  10.         $login = trim($login);
  11.         $login = htmlspecialchars($login);
  12.  
  13.         $password = $_POST['old_pswd'];
  14.         $password = stripslashes($password);
  15.         $password = trim($password);
  16.         $password = htmlspecialchars($password);
  17.  
  18.         $password_new = $_POST['change_pswd'];
  19.         $password_new = stripslashes($password_new);
  20.         $password_new = trim($password_new);
  21.         $password_new = htmlspecialchars($password_new);
  22.  
  23.         $password_new_sec = $_POST['change_pswd_sec'];
  24.         $password_new_sec = stripslashes($password_new_sec);
  25.         $password_new_sec = trim($password_new_sec);
  26.         $password_new_sec = htmlspecialchars($password_new_sec);
  27.  
  28.         if(empty($password_new))
  29.         {
  30.             echo 'Error: Password not specified!';
  31.             echo "<script>setTimeout('location=document.location.href', 8000 )</script>";
  32.         }
  33.  
  34.         if ($password_new == $password_new_sec) {
  35.  
  36.             include 'a_api.php';
  37.            
  38.             $result = $proxy->checkPassword($login, $password);
  39.  
  40.             if (!$result->isOk()) {
  41.                 echo 'Error: Incorrect old account password!';
  42.                 echo "<script>setTimeout('location=document.location.href', 8000 )</script>";
  43.            
  44.             }else{
  45.                 $result = $proxy->changePassword($login, $password_new);
  46.                 if ($result->isOk()) {
  47.                     echo 'Password changed!';
  48.                     echo "<script>setTimeout('location=document.location.href', 8000 )</script>";
  49.                 }else{
  50.                     echo 'Error: ' . $result->toString();
  51.                     echo "<script>setTimeout('location=document.location.href', 8000 )</script>";
  52.                     }
  53.                 }
  54.            
  55.             } else {
  56.                 echo 'Error: Password mismatch!';
  57.                 echo "<script>setTimeout('location=document.location.href', 8000 )</script>";
  58.             }                  
  59.     } else { ?>
  60.  
  61.  
  62. <form method="post" style="max-width:500px;margin:auto">
  63. <h2>Change password</h2>
  64.  
  65. <div class="input-container">
  66.     <i class="fa fa-user icon"></i>
  67.     <input placeholder="Username" class="input-field" type="text" name="name" pattern="[A-Za-z0-9]{4,16}" required />
  68.   </div>
  69.  
  70.  
  71.   <div class="input-container">
  72.     <i class="fa fa-key icon"></i>
  73.     <input placeholder="Old Password" class="input-field" autocomplete="new-password" type="password" name="old_pswd" pattern="[A-Za-z0-9]{4,16}" required />
  74.   </div>
  75.  
  76.   <div class="input-container">
  77.     <i class="fa fa-key icon"></i>
  78.     <input placeholder="New Password" class="input-field" autocomplete="new-password" type="password" name="change_pswd" pattern="[A-Za-z0-9]{4,16}" required />
  79.   </div>
  80.  
  81.   <div class="input-container">
  82.     <i class="fa fa-key icon"></i>
  83.     <input placeholder="Repeat Password" class="input-field" autocomplete="new-password" type="password" name="change_pswd_sec" pattern="[A-Za-z0-9]{4,16}" required />
  84.   </div>
  85.  
  86.   <div class="input-container">
  87.   <button type="submit" class="btn" name="pswd_submit" value="Chanege Password!"> Chanege Password!</button>
  88.   </div>
  89.  
  90.   <p><a href="?">Back to Register Form!</a></p>
  91. </form>
  92.  
  93. <?php }
  94. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement