-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathW_comment.php
More file actions
40 lines (31 loc) · 1.08 KB
/
Copy pathW_comment.php
File metadata and controls
40 lines (31 loc) · 1.08 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
<?php
//including the database connection file
include_once("W_config.php");
if(isset($_POST['submit'])) {
$username = mysqli_real_escape_string($mysqli, $_POST['username']);
$email = mysqli_real_escape_string($mysqli, $_POST['email']);
$comment = mysqli_real_escape_string($mysqli, $_POST['comment']);
// checking empty fields
if(empty($email) || empty($comment) || empty($username)) {
if(empty($email)) {
echo "<font color='red'>Vehicle username field is empty.</font><br/>";
}
if(empty($comment)) {
echo "<font color='red'>Vehicle Registered No field is empty.</font><br/>";
}
if(empty($username)) {
echo "<font color='red'>Vehicle Type field is empty.</font><br/>";
}
}
else {
$sql = "INSERT INTO comments (username,email,comment) VALUES('$username','$email','$comment');";
if ($mysqli->query($sql) === TRUE) {
echo "Thank You for Your Valuable Suggestion ";
header("Location:startpage.html");
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($mysqli);
}
}
}
?>