Registration

<<Back to Main Menu

Description:
Processes Registration Form information to create a new user in the database.

Accessible by:
Users who are not logged in

Accessed from:
Registration Form

Input parameters:
Name
Username
Password
Retype Password
Email
Address1
Address2
Town/City
County/Postcode
Country
Telephone
Title
Card Holder Name
Card Type
Card Expiry
Card Number

Output
If the registration is successful, it will either redirect the user back to the Main Menu or Booking Form (if the user was forced to register because they were trying to book a flight)
If the registration is unsuccessful, it will print the Registration Form again with an error message.

Pseudo Code:
get/create session
if (there is a 'username' param in the session) {
   get form parameters
   validate the form data
   if (form data is ok) {
      if (username is not already in use) {
         insert the data into the database
         if (user tried to enter credit/debit card details) {
            enter the card details into the 'cards' form
         }
         add 'Username' and 'Usertype' params to the session
         if (there is a 'from' param in the session) {
            display success message and redirect to Booking Form
         }
         else {
            display success message and redirect to Main Menu
         }
      }
      else {
         display Registration Form with an error message
      }
   }
   else {
      display Registration Form with relevant error message
   }
}
else {
   display an error message
}