Database Connectivity and Insert New Record
Database Connectivity and Insert New Record
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
2 of 4 13/07/2022, 20:19
index.php file:///home/hagos/index.html
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