/
editprofile.php
112 lines (94 loc) · 2.87 KB
/
editprofile.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
<?php
include("designtemplate.php");
include("database.php");
include("validation.php");
verify_login();
connect();
?>
<?php
$user_id = $_SESSION['user_id'];
?>
<?php
if (isset($_POST['submit_edits'])){
$firstname = $_POST['textbox_FirstName'];
$lastname = $_POST['textbox_LastName'];
$address = $_POST['textbox_Address'];
$gender = $_POST['gender'];
$mobile = $_POST['textbox_Mobile'];
$firstname = htmlspecialchars($firstname);
$lastname = htmlspecialchars($lastname);
$address = htmlspecialchars($address);
if (!valid_name($firstname))
echo "Invalid First name<br/>";
else if (!valid_name($lastname))
echo "Invalid Last name<br/>";
else if (!valid_address($address))
echo "Invalid Address name<br/>";
else if (!ctype_digit($mobile))
echo "Invalid Mobile Number<br/>";
else {
update_user($user_id,'FirstName',$firstname);
update_user($user_id,'LastName',$lastname);
update_user($user_id,'Address',$address);
update_user($user_id,'Gender',$gender);
update_user($user_id,'Mobile',$mobile);
}
}
?>
<?php
$student = get_user_details($_SESSION['user_id']);
$fakes = array();
$fakes['Password'] = true;
$fakes['ID'] = true;
$fakes['AccountType'] = true;
$fakes['Username'] = true;
$fakes['Email'] = true;
?>
<html>
<head>
<title>Edit Profile</title>
</head>
<body>
<form name = "editprofile_form" method = "post">
<?php
foreach($student as $key => $value){
if (isset($fakes[$key]))continue;
echo "<p/>\n";
echo $key."  ";
if ($key == 'Gender'){
if ($value == 'male'){
$male_check = 'checked';
$female_check = 'unchecked';
}
else {
$male_check = 'unchecked';
$female_check = 'checked';
}
echo "<input type = 'radio' name = 'gender' value = 'male' ".$male_check."> Male\n";
echo "  |  \n";
echo "<input type = 'radio' name = 'gender' value = 'female' ".$female_check."> Female\n";
echo "<br/><br/>\n";
}
/*else if ($key == 'AccountType'){
if ($value == 'admin'){
$student_check = 'unchecked';
$admin_check = 'checked';
}
else {
$student_check = 'checked';
$admin_check = 'unchecked';
}
echo "<input type = 'radio' name = 'account_type' value = 'student' ".$student_check."> Student\n";
echo "  |  \n";
echo "<input type = 'radio' name = 'account_type' value = 'admin' ".$admin_check."> Administrator\n";
echo "<br/>\n";
}*/
else echo "<input type = 'text' name = '"."textbox_".$key."' value = '".$value."'><br/><br/>\n";
}
?>
<p/>
<input type = 'submit' name = 'submit_edits' value = 'Edit'>
</form>
</body>
</html>
<?php include("footer.php");?>