-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlectureinsert.php
More file actions
45 lines (33 loc) · 1.12 KB
/
Copy pathlectureinsert.php
File metadata and controls
45 lines (33 loc) · 1.12 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
<!DOCTYPE html>
<html>
<body>
<?php
// servername => localhost
// username => root
// password => empty
// database name => staff
$con = mysqli_connect("localhost", "root", "", "lectures2");
// Check connection
if($con === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
// Taking all 5 values from the form data(input)
$subcode = $_REQUEST['subcode'];
$subname = $_REQUEST['subname'];
$duration = $_REQUEST['duration'];
$nostudent = $_REQUEST['nostudent'];
// Performing insert query execution
// here our table name is college
$sql = "INSERT INTO lectures2_db VALUES ('$subcode',
'$subname','$duration','$nostudent')";
if(mysqli_query($con, $sql)){
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($con);
}
// Close connection
mysqli_close($con);
?>
</body>
</html>