$row = $sth->fetch(); $id = $row['ID']; $name = $row['NAME']; $created_by = $row['ADDED_BY']; $date_added = date('Y-m-d H:i:s', $row['DATE_ADDED']); $roleselect = roleselect($rolearray, $row['ROLE']); // Update post processing if ($_SERVER['REQUEST_METHOD'] == "POST" && $_POST["change"] == "Update") { $dbh->beginTransaction(); $post = 0; $post_message = ''; try { // Has password been updated ? if ($_POST["password"] != "nochange") { // Password validation and hash creation $hash = password_func($_POST["password"], $_POST["password2"]); // Write hash to DB $sth = $dbh->prepare("UPDATE USERS SET HASH = ? WHERE ID = ?"); $sth->bindParam(1, $hash); $sth->bindParam(2, $id); $sth->execute(); $post_message .= '"Password" '; $post++; } // Has role been updated ? if (!is_numeric($_POST["role"]) || !array_key_exists($_POST["role"], $rolearray)) { throw new Exception('Invalid role ID'); } if ($row['ROLE'] != $_POST["role"]) { $sth = $dbh->prepare("UPDATE USERS SET ROLE = ? WHERE ID = ?"); $sth->bindParam(1, $_POST["role"]);
<link rel="stylesheet" href="css/style.css" /> </head> <body> <h1>PASSWORD GENERATOR</h1> <div id="container"> <div id="form_section"> <form action="" method="post"> <label for="given_value"><span class="bold">Password Range:</span></label> <input type="text" name="given_value" id="given_value" /> <input type="submit" name="btn" value="Click" /> </form> </div> <div id="result_section"> <?php if (isset($_POST['btn'])) { $value = $_POST['given_value']; if (is_numeric($value) && !empty($value)) { echo password_func($value); } else { $value = ucwords("expecting integer value"); echo "<span>{$value}</span>"; } } ?> </div> </div> </body> </html>