zzz+special+create+user

new_user.php

code   <?php require_once("includes/form_functions.php");

// START FORM PROCESSING // only execute the form processing if the form has been submitted if (isset($_POST['submit'])) { // initialize an array to hold our errors $errors = array; $message = $_POST['username']. " and ". $_POST['password'];

// perform validations on the form data $required_fields = array('username', 'password'); $errors = array_merge($errors, check_required_fields($required_fields, $_POST));

$fields_with_lengths = array('username' => 50, 'password' => 30); $errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST));

// clean up the form data before putting it in the database $username = trim(mysql_prep($_POST['username'])); $password = trim(mysql_prep($_POST['password'])); $hashed_password = sha1($password);

// Database submission only proceeds if there were NO errors. if (empty($errors)) { $query = "INSERT INTO tblusers (                       username, hashed_password                    ) VALUES (                        '{$username}', '{$hashed_password}'                    )"; if ($result = mysql_query($query, $connection)) { // successful $message = "The user was successfully created."; } else { $message = "The user could not be created."; $message .= " ". mysql_error; }       } else { if (count($errors) == 1) { $message = "There was 1 error in the form."; } else { $message = "There were ". count($errors). " errors in the form."; }       }        // END FORM PROCESSING } else { // Form has not been submitted. $username = ""; $password = ""; } ?>  

Return to Menu

Add User ". $message. " ";} ?>   

 Username:  Password:  

Cancel

 code

.