Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //start new session
- session_start ();
- /**
- * Author: Adam Scheidler
- * Date: 3/30/2012
- * Description: This script writes a new user information into the database
- */
- //set page title
- $page_title = "Create a new user account";
- //include code from header.php and database.php
- require_once('includes/database.php');
- //retrieve user inputs from the form
- $firstname = $_POST['firstname'];
- $lastname = $_POST['lastname'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $role = 2; //regular user
- //insert statement. The id field is an auto field.
- $query_str = "INSERT INTO users VALUES (NULL, '$firstname', '$lastname', '$username', '$password', '$role')";
- //execut the insert query
- $result = @$conn->query($query_str);
- //Handle selection errors
- if (!$result) {
- $errno = $conn->errno;
- $errmsg = $conn->error;
- echo "Insertion failed with: ($errno) $errmsg<br/>\n";
- $conn->close();
- exit;
- }
- $conn->close();
- //create session variables
- $_SESSION['login'] = $username;
- $_SESSION['name'] = $firstname . " " . $lastname;
- $_SESSION['role'] = 2;
- //set login status to 3 since this is a new user.
- $login_status=3;
- //redirect the user to the loginform.php page
- header("Location: loginform.php?ls=$login_status");
- ?>
Add Comment
Please, Sign In to add comment