-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeedbackForm.php
47 lines (39 loc) · 1.55 KB
/
feedbackForm.php
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
46
47
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
// Connecting to the Database
$servername = "localhost";
$username = "root";
$password = "";
$database = "recipeapi";
// Create a connection
$conn = mysqli_connect($servername, $username, $password, $database);
// Die if connection was not successful
if (!$conn){
die("Sorry we failed to connect: ". mysqli_connect_error());
}
else{
// Submit these to a database
// Sql query to be executed
$sql = "INSERT INTO `feedback`(`name`, `email`, `message`) VALUES ('$name', '$email', '$message')";
$result = mysqli_query($conn, $sql);
if($result){
echo '<div class="alert alert-success">
<strong>Success!</strong> Indicates a successful or positive action.
</div>';
}
else{
echo $result;
// echo "The record was not inserted successfully because of this error ---> ". mysqli_error($conn);
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Error!</strong> We are facing some technical issue and your entry ws not submitted successfully! We regret the inconvinience caused!
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
}
}
}
?>