From 4478f1eed395811fbaf70782c272b2eecba9d901 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Mon, 21 Mar 2016 12:08:28 +0100 Subject: [PATCH] Allow a user to change his own password. Closes #62 --- css/base.css | 8 +++++++ index.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/css/base.css b/css/base.css index eaf28cd..a386d81 100644 --- a/css/base.css +++ b/css/base.css @@ -53,6 +53,14 @@ input[type="submit"] { font-weight: bold; padding: 8px; } +input[type="submit"]:disabled { + background: none repeat scroll 0 0 #FF0000; + border: medium none; + color: #FFFFFF; + cursor: pointer; + font-weight: bold; + padding: 8px; +} .label { display: block; margin: 0 10px 0 0; diff --git a/index.php b/index.php index b72137d..2084592 100644 --- a/index.php +++ b/index.php @@ -18,6 +18,16 @@ if (!is_logged_in() and isset($_POST['formname']) and $_POST['formname'] === "lo } } +if (is_logged_in() and isset($_POST['formname']) and $_POST['formname'] === "changepwform") { + if (get_sess_user() == $_POST['username']) { + if (!update_user(get_sess_user(), is_adminuser(), $_POST['password'])) { + $errormsg = "Unable to update password!\n"; + } + } else { + $errormsg = "You can only update your own password!".$_POST['username']; + } +} + ?> @@ -114,9 +124,14 @@ if ($blocklogin === TRUE) {
  • Users
  • +
  • About me
  • Logout
  • + ' . $errormsg . '
    '; + } + ?>
    @@ -129,10 +144,38 @@ if ($blocklogin === TRUE) {
    -
    -
    -
    +
    +
    +
    + +
    +
    +

    Hi . You can change your password here.

    + +
    + + + + + + + + + + + + + + + + + +
    Username:
    Password:
    Password again:
    + +
    +
    +