-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
executable file
·163 lines (145 loc) · 5.94 KB
/
update.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
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
<?php
include 'connection.php';
if(!$_SESSION) {
session_start();
}
if ($_SESSION['valid'] != true) {
$_SESSION['message'] = "Please login!";
header("Location:login.php");
} else {
$_SESSION['message'] = "";
}
$id=$_GET['updateid'];
$output="";
$sql="select * from `student` where id=$id";
$result=mysqli_query($con,$sql);
$row=mysqli_fetch_assoc($result);
$name=$row['name'];
$matric=$row['matric'];
$dob=$row['dob'];
$parent=$row['parent'];
$role=$row['role'];
$phone=$row['phone'];
$genotype=$row['genotype'];
$bloodgroup=$row['bloodgroup'];
if(isset($_POST['update'])){
$name=$_POST['name'];
$matric=$_POST['matric'];
$dob=$_POST['dob'];
$parent=$_POST['parent'];
$role=$_POST['role'];
$phone=$_POST['phone'];
$genotype=$_POST['genotype'];
$bloodgroup=$_POST['bloodgroup'];
$status="Registered";
if(empty($matric)){
$output .= "Matric number can not empty";
} else if(empty($name)){
$output .= "Name can not empty";
} else if(empty($dob)){
$output .= "Please select Date of Birth";
} else if(empty($parent)){
$output .= "Parent name can not empty";
} else if(empty($role)){
$output .= "Please select Parent role";
} else if(empty($phone)){
$output .= "Parent number can not empty";
} else if(empty($genotype)){
$output .= "Please select Genotype";
} else if(empty($bloodgroup)){
$output .= "Please select Blood group";
} else {
$sql="UPDATE `student` SET name='$name',matric='$matric',dob='$dob',parent='$parent',role='$role',
phone='$phone',genotype='$genotype',bloodgroup='$bloodgroup',status='$status' WHERE id=$id" ;
$result=mysqli_query($con,$sql);
if ($result) {
header('location:dashboard.php');
} else {
die(mysqli_error($con));
}
}
}
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php include 'links.php';?>
<title>Register</title>
</head>
<body>
<?php include 'nav.php';?>
<main class="main register-main">
<form method="post" class="form-container">
<div class="login-main-text">
<h2 class="hero-text-main">The Medical Centre</h2>
<h2 class="hero-text">Student Registration</h2>
</div>
<div class="form-input-container">
<div class="error"><b><?php echo $output ?></b></div>
<div class="form-input">
<label for="name">Full Name</label>
<input class="large" type="text" name="name" placeholder="Enter your Full name" minlength="10" required value="<?php echo $name;?>" >
</div>
<div class="form-row">
<div class="form-input">
<label for="matric">Matric No:</label>
<input type="text" name="matric" placeholder="Enter your Matric number" minlength="8" required value="<?php echo $matric;?>">
</div>
<div class="form-input">
<label for="DOB">Date of Birth</label>
<input type="date" name="dob" required value="<?php echo $dob;?>">
</div>
</div>
<div class="form-input">
<label for="parent name">Parent name:</label>
<input class="large" type="text" name="parent" placeholder="Enter your parent's fullname" minlength="10" required value="<?php echo $parent;?>">
</div>
<div class="form-row">
<div class="form-input">
<label for="Parent">Select Parent Role</label>
<select name="role" required value="<?php echo $role;?>">
<option value="Father">Father</option>
<option value="Mother">Mother</option>
</select>
</div>
<div class="form-input">
<label for="parent number">Parent number:</label>
<input type="tel" name="phone" placeholder="Parent's number" minlength="11" required value="<?php echo $phone;?>">
</div>
</div>
<div class="form-row">
<div class="form-input">
<label for="Genotype">Genotype</label>
<select name="genotype" required >
<option value="AA">AA</option>
<option value="AC">AC</option>
<option value="AS">AS</option>
<option value="SS">SS</option>
<option value="SC">SC</option>
</select>
</div>
<div class="form-input">
<label for="Blood Group">Blood Group</label>
<select name="bloodgroup" required>
<option value="+A">+A</option>
<option value="-A">-A</option>
<option value="+AB">+AB</option>
<option value="-AB">-AB</option>
<option value="+B">+B</option>
<option value="-B">-B</option>
<option value="+O">+O</option>
<option value="-O">-O</option>
</select>
</div>
</div>
<div class="form-submit">
<input type="submit" value="update" name="update">
</div>
</div>
</form>
</main>
<?php include 'scripts.php'; ?>
</body>
</html>