-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcontact.php
122 lines (115 loc) · 2.78 KB
/
contact.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
//Joseph Sturzenegger
//U0378425
//PS3
// Start/resume a session. This must be done before any
// output is generated. Create a resumeSave if necessary.
session_start();
//check if name is set
if (!isset($_SESSION['FullName'])) {
$_SESSION['FullName'] = $_REQUEST['FullName'];
}
// Without the =&, we would be copying the array
$fullName =& $_SESSION['FullName'];
//check if address is set
if (!isset($_SESSION['Address'])) {
$_SESSION['Address'] = $_REQUEST['Address'];
}
// Without the =&, we would be copying the array
$address =& $_SESSION['Address'];
//check if phone is set
if (!isset($_SESSION['Phone'])) {
$_SESSION['Phone'] = $_REQUEST['Phone'];
}
// Without the =&, we would be copying the array
$phone =& $_SESSION['Phone'];
$sessionTestName = $_SESSION['FullName'];
$requestTestName = $_REQUEST['FullName'];
$isValidName = false;
// get name if the request is set and it has been changed
if(isset($_REQUEST['FullName']))
{
if($sessionTestName != $requestTestName)
{
getName($errorName, $fullName, $isValidName);
}
}
$sessionTestAddress = $_SESSION['Address'];
$requestTestAddress = $_REQUEST['Address'];
$isValidAddress = false;
// get name if the Address is set and it has been changed
if(isset($_REQUEST['Address']))
{
if($sessionTestAddress != $requestTestAddress)
{
getAddress($errorAddress, $address, $isValidAddress);
}
}
$sessionTestPhone = $_SESSION['Phone'];
$requestTestPhone = $_REQUEST['Phone'];
$isValidPhone = false;
// get name if the Address is set and it has been changed
if(isset($_REQUEST['Phone']))
{
if($sessionTestPhone != $requestTestPhone)
{
getPhone($errorPhone, $phone, $isValidPhone);
}
}
// gets the name and adds it to the session if the field is not blank
function getName(&$message, &$caption, &$valid)
{
$caption = "";
$display = $_REQUEST['FullName'];
$length = strlen($display);
if($length >= 1)
{
$caption = $display;
$_SESSION['FullName'] = $display;
$valid = true;
}
else
{
$message = 'Please enter a name.';
$valid = false;
}
}
// gets the address and adds it to the session if the field is not blank
function getAddress(&$message, &$caption, &$valid)
{
$caption = "";
$display = $_REQUEST['Address'];
$length = strlen($display);
if($length >= 1)
{
$caption = $display;
$_SESSION['Address'] = $display;
$valid = true;
}
else
{
$message = 'Please enter a address.';
$valid = false;
}
}
// gets the phone and adds it to the session if the field is not blank
function getPhone(&$message, &$caption, &$valid)
{
$caption = "";
$display = $_REQUEST['Phone'];
$length = strlen($display);
if($length >= 1)
{
$caption = $display;
$_SESSION['Phone'] = $display;
$valid = true;
}
else
{
$message = 'Please enter a phone number.';
$valid = false;
}
}
// added the page
require('view/page_contact.php');
?>