-
Notifications
You must be signed in to change notification settings - Fork 2
/
contact.php
51 lines (39 loc) · 1.35 KB
/
contact.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
48
49
50
51
<?php
$names = $_POST['names'];
$email = $_POST['email'];
$subjects = $_POST['subjects'];
$messages = $_POST['messages'];
if(!empty($names) || !empty($email) || !empty($subjects) || !empty($messages) )
{
$host = "sql12.freesqldatabase.com";
$dbname = "sql12579871";
$dbUsername = "sql12579871";
$dbPassword = "bMzjcsnss4";
$dbPort = "3306";
$conn = mysqli_connect(hostname: $host, username: $dbUsername, password: $dbPassword, database: $dbname, port: $dbPort);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
}
else {
$sql = "INSERT INTO contactinfo (names, email, subjects, messages) VALUES (?, ?, ?, ?)";
$stmt = mysqli_stmt_init($conn);
if ( ! mysqli_stmt_prepare($stmt, $sql)) {
die(mysqli_error($conn));
}
mysqli_stmt_bind_param($stmt, "ssss",
$names,
$email,
$subjects,
$messages);
mysqli_stmt_execute($stmt);
header("location: index.html");
echo "<script>alert('Message Submitted!');</script>";
$stmt->close();
$conn->close();
}
}
else{
echo "All field are required";
die();
}
?>