-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit.php
80 lines (61 loc) · 2.23 KB
/
edit.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
<?php
# Copyright (c) 2000 Eric Lease Morgan <[email protected]>
# Licensed under the GNU GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html)
?>
<?php
if (! $id) {
# error
$error = "This function requires an ID for input.";
include "./error.inc";
}
elseif (! $submit) {
# create an sql query and execute it
$sql = "SELECT *
FROM member_list
WHERE member_id = $id";
$r = mysql_fetch_array(mysql_query ($sql));
# display the result
include "./edit.inc";
}
else {
# make sure all fields have content
if ($first_name == ""
|| $last_name == ""
|| $address_1 == ""
|| $city == ""
|| $state == ""
|| $zip_code == ""
|| $email == ""
#|| $telephone == ""
#|| $employer == ""
#|| $occupation == ""
#|| $birth_year == ""
) {
# error
$error = "At least one of the required inputs was not supplied.";
include "./error.inc";
}
# update the database
else {
# great, create an sql update query and execute it
$sql = "UPDATE member_list
SET first_name = '$first_name',
last_name = '$last_name',
address_1 = '$address_1',
address_2 = '$address_2',
city = '$city',
state = '$state',
email = '$email',
telephone = '$telephone',
occupation = '$occupation',
employer = '$employer',
birth_year = '$birth_year'
WHERE member_id = $id";
mysql_query ($sql);
# uncomment for debuggin' purposes
#echo mysql_errno().": ".mysql_error()."<BR>"; echo "<pre>$sql</pre>";
# done
echo "<h1>Edited</h1> <p>Thank you.</p>";
}
}
?>