Yellow Jacket
Blue Ridge High School
Yellow Jacket
Home > Web Design > Web II > Add Users

Add Users Form




  1. Create a new PHP file called "login.php" (suggest copying and renaming the adduser page).
    • Create a form that asks for an email (use an email input) and password (use a password input).
  2. Upon submitting the form, verify that the username and password match an existing entry in the users table.
    • Note that you will need to hash the submitted password before checking
    • Use the SQL "SELECT" to search for a matching entry
    • You can use mysqli_num_rows after the query to determine how many matching entries were found.
  3. If a match was found then set a $_SESSION variable equal to a specific value to register the session. Here are a couple of ways that can be done:
    • $_SESSION["loggedin"]="true"
    • $_SESSION["username"]=$username
      • Assuming you stored the username to that variable
  4. After registering the session, send them to a new administrator menu page with links to the pages you already created to add a new user and to edit page content.
  5. Create a new page called "verify.php" that checks to see if the user is logged in prior to accessing the administrator, add user, or edit content pages.
    1. Hint: Check to see if the session variable you created is set to the specified value.
    2. Redirect them to the login page if they are not logged on using the header() function.
    3. Note that the header() MUST be placed prior to the first HTML tag.
    4. Use the require() function on the administrator menu, add user, or edit content pages to run the verify.php program to check the login.
  6. Use your existing company layout for the pages you create.
  7. Validate your form and display page.