-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonAdd.php
More file actions
142 lines (133 loc) · 4.11 KB
/
Copy pathPersonAdd.php
File metadata and controls
142 lines (133 loc) · 4.11 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
include_once 'functions/Person.php';
include_once 'Header.php';
$pID = getIfSet ( "pID" );
$pFName = getIfSet ( "pFName" );
$pLName = getIfSet ( "pLName" );
$pDOB = getIfSet ( "pDOB" );
$pGender = getIfSet ( "pGender" );
$pAdd1 = getIfSet ( "pAdd1" );
$pAdd2 = getIfSet ( "pAdd2" );
$pCity = getIfSet ( "pCity" );
$pState = getIfSet ( "pState" );
$pZip = getIfSet ( "pZip" );
if (isValid_and_set ( "pID" ) && is_numeric ( $_GET ['pID'] )
&& isValid_and_set ( "pFName" ) && isValid_and_set ( "pLName" )
&& isValid_and_set ( "pDOB" ) && isValid_and_set ( "pAdd1" )
&& isValid_and_set ( "pCity" ) && is_numeric ( $_GET ['pState'] )
&& is_numeric ( $_GET ['pZip'] )) {
$insertResult = addPerson ( $pID, $pFName, $pLName, $pDOB, $pGender, $pAdd1, $pAdd2, $pCity, $pState, $pZip );
if ($insertResult == - 1)
showErrorMessage ( "Failed to insert row ID $pID. PK repeated" );
elseif ($insertResult == 0)
showErrorMessage ( "Failed to insert row ID $pID" );
else
showInfoMessage ( "Successfully inserted row ID $pID" );
} else if (isset ( $_GET ['btnAddPerson'] ))
showErrorMessage ( "Please enter valid values" );
?>
<form name="frmAddPerson">
<table style="border: 0px; width: 400px">
<tr>
<td width="100" nowrap="nowrap">
<strong>ID:</strong>
</td>
<td>
<input type=text name=pID value="<?=$pID ?>" />
</td>
</tr>
<tr>
<td>
<strong>First Name:</strong>
</td>
<td>
<input type=text name=pFName value="<?= $pFName ?>" />
</td>
</tr>
<tr>
<td>
<strong>Last Name:</strong>
</td>
<td>
<input type=text name=pLName value="<?= $pLName ?>" />
</td>
</tr>
<tr>
<td>
<strong>Gender:</strong>
</td>
<td>
<input type=radio name=pGender value="M" <?php echo ($pGender == 'M'?"CHECKED":"") ?>>
Male
<input type=radio name=pGender value="F" <?php echo ($pGender == 'F'?"CHECKED":"") ?>>
Female
</td>
</tr>
<tr>
<td>
<strong>DOB:</strong>
</td>
<td>
<input type=text name=pDOB value="<?= $pDOB ?>" />
</td>
</tr>
<tr>
<td>
<strong>Address:</strong>
</td>
<td>
<input type=text name=pAdd1 value="<?= $pAdd1 ?>" />
</td>
</tr>
<tr>
<td> </td>
<td>
<input type=text name=pAdd2 value="<?= $pAdd2 ?>" />
</td>
</tr>
<tr>
<td>
<strong>City:</strong>
</td>
<td>
<input type=text name=pCity value="<?= $pCity ?>" />
</td>
</tr>
<tr>
<td>
<strong>State:</strong>
</td>
<td>
<SELECT name=pState>
<option value="na">Select State</option>
<?php
$result = getAllStates ();
while ( $rows = $result->fetch_assoc () ) {
echo "<option value=\"{$rows['state_id']}\"";
if ($pState == $rows ['state_id'])
echo " SELECTED ";
echo ">{$rows['abb']} - {$rows['name']}</option>";
}
?>
</SELECT>
</td>
</tr>
<tr>
<td>
<strong>Zip:</strong>
</td>
<td>
<input type=text name=pZip value="<?= $pZip ?>" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<button type=submit name=btnAddPerson>Add Person</button>
<button type=reset>Reset</button>
</td>
</tr>
</table>
</form>
<?php
include_once 'footer.php';
?>