-
Notifications
You must be signed in to change notification settings - Fork 0
/
createAccount.php
executable file
·73 lines (53 loc) · 2.24 KB
/
createAccount.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/*
* This file is used to take information from a form and create a customer object
* when the object is created it is added to the database using the CustomerTableGateway.php
*Creates a user accaont for this customer
*/
//files used by this page
require_once 'utils/functions.php';
require_once 'classes/User.php';
require_once 'classes/Customer.php';
require_once 'classes/DB.php';
require_once 'classes/CustomerTableGateway.php';
require_once 'validateCustomer.php';
require_once 'classes/UserTable.php';
$connection = Connection::getInstance();
//calls the validate function passing in the formadata and errors array
//validate prevents the application moving forward untill the validate citria is meet
validate($formdata, $errors);
if (empty($errors))
{
//sets object properties used to set a customer
$branchNo = $formdata['branchNo'];
$fName = $formdata['fName'];
$lName = $formdata['lName'];
$address = $formdata['address'];
$gender = $formdata['gender'];
$mobileNo = $formdata['mobileNo'];
$email = $formdata['email'];
$username = $formdata['email'];
$password = $formdata['password'];
print_r($formdata);
//cretaes a customer object
$cust= new Customer( -1, $branchNo, $fName, $lName, $address, $gender, $mobileNo, $email );
$connection = Connection::getInstance();
$gateway = new CustomerTableGateway($connection);
//print_r($customer);
//sets the branch no to the return from the new branch created
$customerNo = $gateway->newCustomer($cust);
//$customerNo = $gateway->newCust($fName);
//returns to the home page
print_r($customerNo);
start_session();
$user = new User(null, $email, $password, "customer");
$userTable = new UserTable($connection);
$id = $userTable->insert($user, $customerNo);
$user->setId($id);
$_SESSION['user'] = $user;
header('Location: myAccount.php');
}
else
{
require 'signUpCreateCustomerForm.php';
}