Repository navigation
Expand file tree
/
Copy pathcreate_student.php
More file actions
79 lines (67 loc) · 2.54 KB
/
Copy pathcreate_student.php
File metadata and controls
79 lines (67 loc) · 2.54 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<title>student creation</title>
</head>
<body>
<?php include 'connection.php'; ?>
<div class = "container">
<div>
<h2>create Student</h2>
</div>
<div class = "col-md-7">
<form method="post" action="create_student.php">
<div class="form-group">
<label for="">Student Name</label>
<input type="text" class="form-control" name="name" id="">
</div>
<div class="form-group">
<label for="">Email</label>
<input type="email"class="form-control" name="email" id="">
</div>
<div class="form-group">
<label for="">Date of Birth</label>
<input type="date" class="form-control" name="dob" id="">
</div>
<div class="form-group">
<label for="">Department</label>
<select name="dept_id" id="" class="form-control">
<?php
$query = "SELECT id, short_code FROM departments";
$sql = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($sql))
{ ?>
<option value="<?php echo $row['id'] ?>" > <?php echo $row['short_code'] ?> </option>
<?php
}
?>
</select>
</div>
<div class="form-group">
<input type="submit" name="submit" class="btn btn-primary" value="add student">
</div>
</form>
</div>
</div>
</body>
</html>
<?php
include 'connection.php';
if(isset($_POST['submit']))
{
//recvd data from input/control
$name = $_POST['name'];
$email = $_POST['email'];
$dob = $_POST['dob'];
$dept_id = $_POST['dept_id'];
//db query
$query = "INSERT INTO `student`( `name`, `email`, `dob`, `department_id`) VALUES ('$name', '$email', '$dob', '$dept_id')";
if(mysqli_query($conn, $query))
{
echo "success!!";
}
}
?>