From ca258c49fcd45f56abacd68dfbf7a2fb96a3c080 Mon Sep 17 00:00:00 2001 From: Josh North Date: Thu, 19 Feb 2015 22:41:20 -0500 Subject: [PATCH] updated to add delete... --- reports.php | 6 +++--- users.php | 32 +++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/reports.php b/reports.php index cb3a299..f259303 100755 --- a/reports.php +++ b/reports.php @@ -35,7 +35,7 @@ if ($_POST['reporttype'] == "Hours per week per user") { $query = "SELECT YEAR(punches.intime) AS g_year, WEEK(punches.intime) AS g_week, -SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600) AS punchhours, +ROUND(SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600),2) AS punchhours, punches.id as punchid, users.id as user, users.username as username, @@ -79,8 +79,8 @@ echo ''; elseif ($_POST['reporttype'] == "Hours per month per user") { $query = "SELECT YEAR(punches.intime) AS g_year, -MONTH(punches.intime) AS g_month, -SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600) AS punchhours, +MONTHNAME(punches.intime) AS g_month, +ROUND(SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600),2) AS punchhours, punches.id as punchid, users.id as user, users.username as username, diff --git a/users.php b/users.php index 3f7e7a1..47b7f8b 100755 --- a/users.php +++ b/users.php @@ -13,7 +13,7 @@ echo "

Add User

"; echo "

Use the following form to add users to the system. Passwords must be 8+ characters. Email must be filled out, and username must be unique.

"; require_once($yaptc_lib . "phpass-0.3/PasswordHash.php"); -if (!empty($_POST)) +if (!empty($_POST['newuser'])) { if (empty($_POST['username'])) { @@ -97,7 +97,7 @@ if (!empty($_POST)) * If the form has been submitted and no errors were detected, we can proceed * to account creation. */ -if (!empty($_POST) && empty($errors)) +if (!empty($_POST['newuser']) && empty($errors)) { /** * Hash password before storing in database @@ -177,17 +177,34 @@ if (!empty($_POST) && empty($errors)) - + - - + prepare("DELETE FROM users WHERE users.id=$deleteid"); +$deletequery->execute(); +echo "user deleted!"; + if ($deletequery !== false) { + + header("Location: {$_SERVER['PHP_SELF']}", true, 303); + exit; + } +} +} + + echo "

User List

"; echo "

Current users. To edit, select the edit button in the right column.

"; $result = $sql->prepare("SELECT users.id as userid, users.username as username, users.email as email, users.created as created, users.firstname as firstname, users.lastname as lastname, users.usertype as usertypeid, usertypes.typename as usertype @@ -204,6 +221,7 @@ echo 'Username'; echo 'Email'; echo 'Created'; echo 'User Type'; +echo 'Actions'; echo ''; echo ''; echo ''; @@ -216,6 +234,10 @@ echo "" . $row['username'] . ""; echo "" . $row['email'] . ""; echo "" . $row['created'] . ""; echo "" . $row['usertype'] . ""; +?>
+ +
+"; } echo '';