Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if((isset($_POST['haslo']))&&isset($_POST['haslo1'])&&isset($_POST['haslo2']))
- {
- $walidacja=true;
- $user = $_SESSION['user'];
- $starehaslo = $_POST['haslo'];
- $nowehaslo1 = $_POST['haslo1'];
- $nowehaslo2 = $_POST['haslo2'];
- if (strlen($starehaslo)<1)
- {
- $walidacja=false;
- $_SESSION['e_starehaslo']= "Proszę podać aktualne hasło.<br>";
- $_SESSION['e_div']= true;
- }
- if (strlen($nowehaslo1)<8)
- {
- $walidacja=false;
- $_SESSION['e_haslo']= "Nowe hasło powinno mieć co najmniej 8 znaków.<br>";
- $_SESSION['e_div']= true;
- }
- if ($nowehaslo1 !=$nowehaslo2)
- {
- $walidacja=false;
- $_SESSION['e_haslo']= "Podane hasła nie są takie same.<br>";
- $_SESSION['e_div']= true;
- }
- $haslo_hash = password_hash($nowehaslo1, PASSWORD_DEFAULT);
- require_once "connect.php";
- mysqli_report(MYSQLI_REPORT_STRICT);
- try
- {
- $polaczenie= mysqli_connect($host,$db_user,$db_password,$db_name);
- if ($polaczenie->connect_errno!=0)
- {
- throw new Exception(mysqli_connect_errno());
- }
- else
- {
- if($walidacja==true)
- {
- $zmiana = "UPDATE uzytkownicy SET pass = '$haslo_hash' WHERE user='$user'";
- if ($polaczenie->query($zmiana) === true)
- {
- echo '<div id="panel" style="display:none;">Hasło zostało zmienione</div>';
- }
- else{
- throw new Exception($polaczenie->error);
- }
- }
- $polaczenie->close();
- }
- }
- catch(Exception $e)
- {
- echo'<br />info: '.$e;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement