-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchange_passwd.php
30 lines (28 loc) · 909 Bytes
/
change_passwd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require_once('bookmark_fns.php');
session_start();
do_html_header('Changing password');
// create short variable names
$old_passwd = $_POST['old_passwd'];
$new_passwd = $_POST['new_passwd'];
$new_passwd2 = $_POST['new_passwd2'];
try
{
check_valid_user();
if (!filled_out($_POST))
throw new Exception('You have not filled out the form completely. Please try again.');
if ($new_passwd!=$new_passwd2)
throw new Exception('Passwords entered were not the same. Not changed.');
if (strlen($new_passwd)>16 || strlen($new_passwd)<6)
throw new Exception('New password must be between 6 and 16 characters. Try again.');
// attempt update
change_password($_SESSION['valid_user'], $old_passwd, $new_passwd);
echo 'Password changed.';
}
catch (Exception $e)
{
echo $e->getMessage();
}
display_user_menu();
do_html_footer();
?>