-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.php
More file actions
43 lines (32 loc) · 955 Bytes
/
Copy pathcomment.php
File metadata and controls
43 lines (32 loc) · 955 Bytes
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
<?php
$insert=false;
if(isset($_POST['name'])){
// Set connection variables
$server = "localhost";
$username = "root";
$password = "";
// Create a database connection
$con = mysqli_connect($server, $username, $password);
// Check for connection success
if(!$con){
die("connection to this database failed due to" . mysqli_connect_error());
}
// echo "Success connecting to the db";
// Collect post variables
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['commennt'];
$sql = "INSERT INTO `member`.`comment` ( `name`, `email`, `comment`, `dt`)
VALUES ( '$name', '$email', '$comment', current_timestamp());";
if($con->query($sql) == true){
echo "Successfully inserted";
// Flag for successful insertion
$insert = true;
}
else{
echo "ERROR: $sql <br> $con->error";
}
// Close the database connection
$con->close();
}
?>