0% found this document useful (0 votes)
36 views4 pages

Database Connectivity and Insert New Record

This PHP code is for a student information management system. It includes a form to register new students with fields for ID, name, department, age and sex. It also includes code to insert registered student data into a database table.

Uploaded by

gezaegebre1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

Database Connectivity and Insert New Record

This PHP code is for a student information management system. It includes a form to register new students with fields for ID, name, department, age and sex. It also includes code to insert registered student data into a database table.

Uploaded by

gezaegebre1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

index.php file:///home/hagos/index.

html

/var/www/html/Try/index.php
1 <?php
2 include('db_config.php');
3 if (isset($_POST['register'])) {
4 $ID = $_POST['stud_id'];
5 $Name = $_POST['stud_name'];
6 $dpt = $_POST['stud_dpt'];
7 $age = $_POST['stud_age'];
8 $sex = $_POST['stud_sex'];
9
10 $stmt = $conn->prepare("INSERT INTO student(stud_id,stud_name,stud_dpt,age,sex) VALUES(?,?,?,?,?)");
11 $stmt->bind_param("sssis", $ID, $Name, $dpt, $age, $sex);
12 $info = $stmt->execute();
13 if ($info) {
14 $msg = "$Name is Successfully Registered";
15 $stmt->close();
16 $conn->close();
17 } else {
18 $msg = "Not Registered.";
19 }
20 }
21 ?>
22 <html>
23 <head>
24 <title>SIMS</title>
25 <!-- External Bootstrap CSS File -->
26 <link rel="stylesheet" href="css/bootstrap.min.css">
27 </head>
28
29 <body>
30 <!-- The first Row that contains Headers and top navigations -->
31 <div class="row">
32 <!-- First Columns(col1 and col2) with Empty contents -->
33 <div class="col-md-2"></div>
34
35 <!-- Second columns(col3,co4,.....,col8) with Site header and top Navigations-->
36 <div class="col-md-8">
37 <nav class="navbar navbar-default">
38 <div class="container-fluid">
39 <div class="navbar-header">

1 of 4 13/07/2022, 20:19
index.php file:///home/hagos/index.html

40 <a class="navbar-brand" href="#">Student Information Managment System</a>


41 </div>
42 <ul class="nav navbar-nav">
43 <li class="active"><a href="index.php">Registration</a></li>
44 <li><a href="#">Student</a></li>
45 <li><a href="#">Course</a></li>
46 <li><a href="#">Login</a></li>
47 <li><a href="#">DownLoad</a></li>
48 </ul>
49 </div>
50 </nav>
51 </div>
52 <!-- Third Columns(col11,col12) with empty content -->
53 <div class="col-md-2"></div>
54
55 </div>
56 <!-- Second Row -->
57 <div class="row">
58
59 <div class="col-md-2"></div>
60
61 <div class="col-md-8">
62 <?php
63 if (isset($msg)) {
64 ?>
65 <div class="alert alert-success">
66 <?php echo "<strong>Well Done.</strong> " . $msg; ?>
67 </div>
68 <?php
69 }
70 ?>
71
72 <form class="form-horizontal" action="" method="POST">
73
74 <div class="form-group">
75 <label class="control-label col-sm-2">Student ID:</label>
76 <div class="col-sm-6">
77 <input type="text" class="form-control" name="stud_id" placeholder="Enter Student ID" required="">
78 </div>
79 </div>
80
81 <div class="form-group">

2 of 4 13/07/2022, 20:19
index.php file:///home/hagos/index.html

82 <label class="control-label col-sm-2">Student Name:</label>


83 <div class="col-sm-6">
84 <input type="text" class="form-control" name="stud_name" placeholder="Enter Student Name" required="">
85 </div>
86 </div>
87
88 <div class="form-group">
89 <label class="control-label col-sm-2">Department:</label>
90 <div class="col-sm-6">
91 <select class="form-control" name="stud_dpt" required="">
92 <option>Web Programming</option>
93 <option>Android Programming</option>
94 <option>Artificial Intelligence</option>
95 <option>Django Training</option>
96 </select>
97
98 </div>
99 </div>
100
101 <div class="form-group">
102 <label class="control-label col-sm-2">Age:</label>
103 <div class="col-sm-6">
104 <input type="number" class="form-control" name="stud_age" placeholder="Enter Student Age" required="">
105 </div>
106 </div>
107
108
109 <div class="form-group">
110 <label class="control-label col-sm-2">Sex:</label>
111 <div class="col-sm-6">
112 <input type="radio" name="stud_sex" checked>Male
113 <input type="radio" name="stud_sex">Female
114 </div>
115 </div>
116
117 <div class="form-group">
118 <div class="col-sm-offset-2 col-sm-10">
119 <button type="submit" class="btn btn-success" name="register">Register</button>
120 </div>
121 </div>
122
123 </form>

3 of 4 13/07/2022, 20:19
index.php file:///home/hagos/index.html

124 </div>
125
126 <div class="col-md-2"></div>
127
128 </div>
129 </body>
130 </html>
131

4 of 4 13/07/2022, 20:19

You might also like