M-V-C User management page
Welcome to ComputerTechMonkey.net
Model
- Establish session access
- Establish database connectivity
- function reg_user($vfName, $vlName, $vuName, $vemail, $vpassword){
- get global access to database connections and variables
- hash the password
- write the sql insert statement
- set up prepared statement
- bind parameters
- execute prepared statement
- test for successful insert
- if successful, set success message
- if failure, set failure message
- close prepared statement
- return message
- }
- function list_mem(){
- get global access to database connections and variables
- write the sql select statement
- set up prepared statement
- execute prepared statement
- bind results
- set up multi dimensional array
- while loop to assign results to array
- close prepared statement
- return array
- }
- function edit_user($editID){
- get global access to database connections and variables
- write the sql select statement
- set up prepared statement
- execute prepared statement
- bind results
- set up array
- while loop to assign results to array
- close prepared statement
- return array
- }
- function update_user($userid, $fname, $lname, $uName, $email, $password, $password2){
- get global access to database connections and variables
- if statement to check for update of password
- if statement to write the proper sql update statement
- one statement for password and other for no password update
- set up prepared statement
- if statement to bind parameters for either with or without password
- execute prepared statement
- test for successful insert
- if successful, set success message
- if failure, set failure message
- close prepared statement
- return message
- }
- function del_user($delID){
- get global access to database connections and variables
- write the sql select statement
- set up prepared statement
- execute prepared statement
- bind results
- set up array
- while loop to assign results to array
- close prepared statement
- return array
- }
- function rem_user($delID){
- get global access to database connections and variables
- write the sql delete statement
- set up prepared statement
- bind parameters
- execute prepared statement
- test for successful delete
- if successful, set success message
- if failure, set failure message
- close prepared statement
- return message
- }
View
Description:
The member who wants to register will be given this view. All fields will
be required, the security code is for filtering of users.
The firstname, lastname, username, email and password will be the only data actually
stored in the database.
Description:
A registered member will be able to access this view to edit /
update his or her information. The First 4 fields will be required to have data.
The password is optional only if the member wishes to update their password
Description:
This view is for listing all registered members. It will allow for editing or deletion of a member.
Description:
This view is to confirm the deletion of a member on the site.
Control
Establish session access Establish logic structure for all expected interactionsCode for registering a new member
- if(member registration data is submitted){
- collect the incoming data
- if statements to validate the different pieces of data
- if (invalidate data is found) {
- write an error message
- write error message and errors array to session
- redirect back to the registration page to allow errors to be fixed
- }
- if (all data is valid){
- call the reg_user function
- get back the message
- store message in session
- redirect to register user page
- }
Code for requesting to edit member info
- if(edit member data request is submitted){
- collect the users id number
- call the edit_user function
- store user id in session
- redirect to edit user page
- }
Code for updating a new member
- if(update request is submitted){
- collect the incoming data
- call the update_user function and set returned message to a variable
- store message in session
- redirect edit user page to show message
- }
Code for requesting to delete member
- if(edit member data request is submitted){
- collect the delid number
- call the del_user function
- set returned user array to a variable
- store user array in session
- redirect to edit user page
- }
Code to delete a member
- if(update request is submitted){
- collect the incoming data
- call the rem_user function
- set returned message to a variable
- store message in session
- redirect del user page to show message
- }
Code to list members
- else{
- call the list_user function
- set returned array to a variable
- store array in session
- redirect to list user page to list all registered users
- }
