-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect.php
46 lines (37 loc) · 1.16 KB
/
connect.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
<?php
// Enable error reporting for debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);
// getting all values from the HTML form
if(isset($_POST['submit']))
{
$full_name = $_POST['full_name'];
$email = $_POST['email'];
$phone_number = $_POST['phone_number'];
$topic = $_POST['topic'];
}
// database details
$host = "localhost";
$username = "root";
$password = "";
$dbname = "coffee";
// creating a connection
$con = mysqli_connect($host, $username, $password, $dbname);
// to ensure that the connection is made
if (!$con)
{
die("Connection failed!" . mysqli_connect_error());
}
// using sql to create a data entry query
$sql = "INSERT INTO info (full_name, email, phone_number, topic) VALUES ('$full_name', '$email', '$phone_number','$topic' )";
// send query to the database to add values and confirm if successful
$rs = mysqli_query($con, $sql);
if($rs)
{
header("Location: thankyou.html");
exit();
//echo "Feedback Received, We will contact you shortly!";
}
// close connection
mysqli_close($con);
?>