-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.php
More file actions
200 lines (177 loc) · 6.98 KB
/
update.php
File metadata and controls
200 lines (177 loc) · 6.98 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php include"header.php";?>
<?php
if (!isset($_SESSION['login'])) {
header('location:index.php');
}
?>
<?php
$message="";
$id=$_GET['U'];
if (isset($_POST['send'])) {
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$Gender=$_POST['Gender'];
$dob=$_POST['dob'];
$exdate=$_POST['date'];
$phone_number=$_POST['phone_number'];
$idlength=strlen($phone_number);
$year=date('Y');
$useryear=date('Y', strtotime($dob));
$validyear=$year-$useryear;
if ($fname=='' or $lname=='' or $Gender==''or $dob==''or $exdate==''or $phone_number=='') {
$message= "<div class='alert alert-danger'> <i class='fa fa-info-circle'></i> Fill all fields</div>";
}else{
if ($validyear < 18) {
$message="<div class='alert alert-danger'><i class='fa fa-info-circle'></i>Allowed Candidate are those with more than 18 years </div>";
$_SESSION['message_request']=$message;
}else{
$selectall=mysqli_query($conn, "SELECT * FROM candidate where candidatanationalid='$id'")or die($con->error);
$myfecthall=mysqli_fetch_array($selectall);
if ($idlength!=10) {
$message="<div class='alert alert-danger'>
<i class='fa fa-info-circle'></i>
enter valid phone number 12 numbers</div>";
}else{
$sg=mysqli_query($conn, "UPDATE candidate SET firstname='$fname',lastname='$lname',gender='$Gender',dob='$dob',examdate='$exdate',phonenumber='$phone_number' WHERE candidatanationalid='$id'");
if ($sg) {
$message="<div class='alert alert-success'><i class='fa fa-info-circle'></i> Candidate Updated successful</div>";
} else{
$message="<div class='alert alert-danger'> <i class='fa fa-info-circle'></i> ".$conn->error."</div>";
}
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>RDL _ Rwanda driving license</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/all.min.js"></script>
<script type="text/javascript" src="js/all.js"></script>
<script type="text/javascript" src="js/fontawesome.js"></script>
<script type="text/javascript" src="js/fontawesome.js"></script>
<script type="text/javascript" src="vendor/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="js/fontawesome.css">
<link rel="stylesheet" type="text/css" href="js/all.css">
<link rel="stylesheet" type="text/css" href="js/all.mini.css">
<link rel="stylesheet" type="text/css" href="js/fontawesome.min.css">
<style type="text/css">
table th{
color: rgba(245, 6, 170,0.90)
}
table tr{
border-bottom:1px solid rgba(245, 6, 170,0.90)
}
a:hover{
border-top: 1px solid white;
}
.home{
border-top: 1px solid white;
}
</style>
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-3" style="
margin: 0;
position: absolute;
top: 20%;
left: 4%;
overflow: hidden;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
">
<?php echo$message?>
</div>
<div class="col-lg-3"
style="
margin: 0;
position: absolute;
top: 40%;
left: 4%;
overflow: hidden;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
">
<a href="candidatelist.php" class="font-weight-bold text-decoration-none" style="
color: rgba(245, 6, 170, 1);
"><i class="fa fa-arrow-alt-circle-left" title="back to login" style="font-size: 20px"></i><span>Back </span>
</a>
</div>
<div class="col-lg-6 ml-5">
<form class="row ml-5 sticky-top" method="POST">
<div class="col-lg-12 sticky-top" style="
background-color:rgb(245, 6, 170);
color: white;
padding: 10px;
">
Update Candidate <strong>with ID#<?php echo$_GET['U']?></strong>
</div>
<?php
$id=$_GET['U'];
$selectall=mysqli_query($conn, "SELECT * FROM candidate where candidatanationalid='$id' ")or die($con->error);
if (mysqli_num_rows($selectall)>0) {
$myfecthall=mysqli_fetch_array($selectall);
?>
<div class="col-lg-12">
<label>Candidate national id</label>
<input type="number" name="candidate_national_id" class="form-control" disabled value="<?php echo$_GET['U']?>">
<small class="text-danger"><i class='fa fa-info-circle'></i> National id can't be changed</small>
</div>
<div class="col-lg-12 mt-3">
<label>First Name</label>
<input type="text" name="fname" value="<?php echo($myfecthall['firstname'])?>" class="form-control" >
</div>
<div class="col-lg-12 mt-3">
<label>Last Name</label>
<input type="text" name="lname" value="<?php echo($myfecthall['lastname'])?>" class="form-control">
</div>
<div class="col-lg-12 mt-3">
<label>Gender</label><br>
<?php if ($myfecthall['gender']=='female') {?>
<input type="radio" name="Gender" value="female" checked>Female
<input type="radio" value="male" name="Gender" >Male
<?php
}else{ ?>
<input type="radio" name="Gender" value="female" >Female
<input type="radio" value="male" name="Gender" checked>Male
<?php }
?>
</div>
<div class="col-lg-12 mt-3">
<label>Date of birth</label>
<input type="date" name="dob" value="<?php echo($myfecthall['dob'])?>" class="form-control">
</div>
<div class="col-lg-12 mt-3">
<label>Exam Date</label>
<input type="date" value="<?php echo($myfecthall['examdate'])?>" name="date" class="form-control">
</div>
<div class="col-lg-12 mt-3">
<label>Phone number</label>
<input type="number" value="<?php echo($myfecthall['phonenumber'])?>" name="phone_number" class="form-control">
</div>
<div class="col-lg-12 mt-3" >
<button class="btn btn-sm" name="send" type="submit" style="
background-color:rgba(245, 6, 170,1);
color: white;
padding: 10px;
">
Confirm
</button>
</div>
<?php }else{?>
<div class='col-lg-12 alert alert-danger'><i class='fa fa-info-circle'></i> No candidate found</div>
<?php }?>
</form>
</div>
</div>
</div>