function addAdminUser() { $controller = new ControllerAuthentication(); if (!$controller->checkUsername($_POST['username'])) { $itm = new Authentication(); $itm->name = trim(strip_tags($_POST['name'])); $itm->username = trim(strip_tags($_POST['username'])); $pass = trim(strip_tags($_POST['password'])); $password_confirm = trim(strip_tags($_POST['password_confirm'])); $itm->password = md5($pass); if (strlen($pass) < 8) { echo "<script >alert('Password field must be atleast 8 alphanumeric characters.');</script>"; } else { if ($pass != $password_confirm) { echo "<script >alert('Password does not match.');</script>"; } else { $controller->insertAccessUser($itm); echo "<script type='text/javascript'>location.href='admin_access.php';</script>"; } } } else { echo "<script >alert('Username already taken.');</script>"; } }
<?php require_once 'header.php'; $controller = new ControllerAuthentication(); if (isset($_POST['submit'])) { if (!$controller->checkUsername($_POST['username'])) { $itm = new Authentication(); $itm->name = trim(strip_tags($_POST['name'])); $itm->username = trim(strip_tags($_POST['username'])); $pass = trim(strip_tags($_POST['password'])); $password_confirm = trim(strip_tags($_POST['password_confirm'])); $itm->password = md5($pass); if (strlen($pass) < 8) { echo "<script >alert('Password field must be atleast 8 alphanumeric characters.');</script>"; } else { if ($pass != $password_confirm) { echo "<script >alert('Password does not match.');</script>"; } else { $controller->insertAccessUser($itm); echo "<script type='text/javascript'>location.href='admin_access.php';</script>"; } } } else { echo "<script >alert('Username already taken.');</script>"; } } ?> <!DOCTYPE html> <html lang="en"><head>