-
Notifications
You must be signed in to change notification settings - Fork 4
/
contact.php
65 lines (48 loc) · 1.48 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
session_start();
// //SET THE HOST
// $host ="localhost";
// $username ="root";
// $pwd="";
// $database ="ecycle1";
// $fname="";
// $email="";
// $message="";
// // //creating a connection to the server
$connection =mysqli_connect('localhost', 'root', '', 'ecycle1');
//checking if connection is succesful
if(!$connection){
die("could not connect to server" . mysqli_connect_error());
}
// $connection = mysqli_connect( $host, $username, $pwd, $database);
// if($connection){
// }else{
// die("ERROR: Could not connect. " . mysqli_connect_error());
// }
if(isset($_POST['Send'])) {
$fname = mysqli_real_escape_string($connection, $_POST['fname']);
$message = mysqli_real_escape_string($connection, $_POST['message']);
$email = mysqli_real_escape_string($connection, $_POST['email']);
// checking empty fields
if(empty($fname) || empty($message) || empty($email)) {
if(empty($fname)) {
echo "<font color='red'>Name field is empty.</font><br/>";
}
if(empty($message)) {
echo "<font color='red'>Message field is empty.</font><br/>";
}
if(empty($email)) {
echo "<font color='red'>Email field is empty.</font><br/>";
}
//link to the previous page
echo "<br/><a href='javascript:self.history.back();'>Go Back</a>";
} else {
// if all the fields are filled (not empty)
$_SESSION['fname'] = $fname;
$_SESSION['message'] = $message;
$_SESSION['email'] = $email;
header('location: faq.html');
}
}
//mysqli_close($connection);
?>