diff --git a/webui/user-add.php b/webui/user-add.php index ae3fc7bc8118ac27a25b6451a0086c82d8c20f2e..c27a4ad2211f8efca8554d1cfab3afa102ed4a5a 100644 --- a/webui/user-add.php +++ b/webui/user-add.php @@ -21,12 +21,8 @@ include_once("includes/footer.php"); include_once("includes/db.php"); include_once("includes/tooltips.php"); - - $db = connect_db(); - - printHeader(array( "Tabs" => array( "Back to user list" => "policy-main.php" @@ -34,11 +30,9 @@ printHeader(array( )); - if ($_POST['frmaction'] == "add") { ?> <p class="pageheader">Add user</p> - <form method="post" action="user-add.php"> <div> <input type="hidden" name="frmaction" value="add2" /> @@ -55,27 +49,25 @@ if ($_POST['frmaction'] == "add") { </tr> </table> </form> - <?php # Check we have all params } elseif ($_POST['frmaction'] == "add2") { ?> <p class="pageheader">User Add Results</p> - <?php # Check name if (empty($_POST['user_name'])) { ?> <div class="warning">Username cannot be empty</div> <?php - + # Add to database } else { $stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}users (Username) VALUES (?)"); - $res = $stmt->execute(array( - $_POST['user_name'], - )); + $_POST['user_name'], + )); + # Was it successful? if ($res) { ?> <div class="notice">User added</div> @@ -95,6 +87,5 @@ if ($_POST['frmaction'] == "add") { printFooter(); - # vim: ts=4 ?>