-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_student.php
More file actions
48 lines (39 loc) · 1.24 KB
/
add_student.php
File metadata and controls
48 lines (39 loc) · 1.24 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
<?php
include("db_connection.php");
// Check if form submitted
if(isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$course = $_POST['course'];
// Insert student into database
$sql = "INSERT INTO student (name, email, course) VALUES ('$name', '$email', '$course')";
if(mysqli_query($conn, $sql)) {
echo "<p style='color:green'>Student registered successfully!</p>";
} else {
echo "<p style='color:red'>Error: " . mysqli_error($conn) . "</p>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Registration</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Student Registration</h2>
<form method="post" action="">
<label>Name:</label><br>
<input type="text" name="name" required><br><br>
<label>Email:</label><br>
<input type="email" name="email" required><br><br>
<label>Course:</label><br>
<input type="text" name="course" required><br><br>
<input type="submit" name="submit" value="Register Student">
</form>
<br>
<a href="index.php">Back to Home</a>
</body>
</html>