| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- use App\MyUser;
- if (!isset($_SESSION['login'])){
- header('Location: signin');
- exit();
- }
- if (!isset($_POST['passwd'], $_POST['passwdconf'])) {
- header('Location: signin');
- exit();
- }
- if (empty($_POST['passwd']) || empty($_POST['passwdconf'])) {
- header('Location: signin');
- exit();
- }
-
- $passwd = htmlspecialchars($_POST['passwd']);
- $passwdconf = htmlspecialchars($_POST['passwdconf']);
-
- if ($passwd != $passwdconf) {
- header('Location: signin');
- exit();
- }
-
- try {
- $user = new MyUser($_SESSION['login'], $passwd);
- $user->changePassword();
- header('Location: welcome');
- exit();
- }
- catch (Exception $e) {
- $_SESSION['message'] = $e->getMessage();
- header('Location: signin');
- exit();
- }
|