Advertisement
Guest User

Untitled

a guest
Mar 5th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.35 KB | None | 0 0
  1. if((isset($_POST['haslo']))&&isset($_POST['haslo1'])&&isset($_POST['haslo2']))
  2. {                                                                                                                          
  3. $walidacja=true;    
  4. $user = $_SESSION['user'];
  5. $starehaslo = $_POST['haslo'];
  6. $nowehaslo1 = $_POST['haslo1'];
  7. $nowehaslo2 = $_POST['haslo2'];
  8.     if (strlen($starehaslo)<1)
  9.     {
  10.         $walidacja=false;
  11.         $_SESSION['e_starehaslo']= "Proszę podać aktualne hasło.<br>";
  12.         $_SESSION['e_div']= true;
  13.     }
  14.      
  15.      
  16.      
  17.     if (strlen($nowehaslo1)<8)
  18.     {
  19.         $walidacja=false;
  20.         $_SESSION['e_haslo']= "Nowe hasło powinno mieć co najmniej 8 znaków.<br>";
  21.         $_SESSION['e_div']= true;
  22.     }
  23.     if ($nowehaslo1 !=$nowehaslo2)
  24.     {
  25.         $walidacja=false;
  26.         $_SESSION['e_haslo']= "Podane hasła nie są takie same.<br>";
  27.         $_SESSION['e_div']= true;
  28.     }
  29.      $haslo_hash = password_hash($nowehaslo1, PASSWORD_DEFAULT);
  30.      
  31.      require_once "connect.php";
  32.       mysqli_report(MYSQLI_REPORT_STRICT);
  33.        
  34.     try
  35.             {
  36.                 $polaczenie= mysqli_connect($host,$db_user,$db_password,$db_name);
  37.                     if ($polaczenie->connect_errno!=0)
  38.                     {
  39.                         throw new Exception(mysqli_connect_errno());
  40.                     }
  41.                     else
  42.                     {
  43.                          
  44.      
  45.     if($walidacja==true)
  46.     {
  47.         $zmiana = "UPDATE uzytkownicy SET pass = '$haslo_hash' WHERE user='$user'";
  48.                                 if ($polaczenie->query($zmiana) === true)
  49.                                 {                                                                                                                                      
  50.                                     echo '<div id="panel" style="display:none;">Hasło zostało zmienione</div>';                                            
  51.                                 }
  52.                                  else{
  53.                                         throw new Exception($polaczenie->error);
  54.                                         }
  55.                              }
  56.                         $polaczenie->close();
  57.                     }
  58.     }
  59.  
  60.             catch(Exception $e)
  61.             {
  62.                 echo'<br />info: '.$e;
  63.             }
  64.     }
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement