-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.php
96 lines (88 loc) · 3.5 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
session_start();
if(!isset($_SESSION['fullName'])){
header('location:login.php');
exit();
}
$success = false;
$error = false;
include 'connect.php';
$icon = "";
$selectquery = "SELECT * FROM `navbar4`";
$query = mysqli_query($con, $selectquery);
if($query){
$fav_icon = mysqli_fetch_assoc($query);
$icon = $fav_icon['Image'];
}
if(isset($_POST['submit'])){
$fname = $_POST['fname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$address = $_POST['address'];
$message = $_POST['message'];
$selectquery = "SELECT * FROM `contact363` WHERE `FullName`='$fname' AND `Phone_No`='$phone' AND `Email`='$email' AND `Address`='$address' AND `Message`='$message'";
$result = mysqli_query($con,$selectquery);
if(mysqli_num_rows($result) > 0){
$success = true;
}else{
$insertquery = "INSERT INTO `contact363` (`FullName`, `Phone_No`, `Email`, `Address`, `Message`, `Time`) VALUES ('$fname', '$phone', '$email', '$address', '$message', current_timestamp())";
$query = mysqli_query($con, $insertquery);
if($query){
$success = true;
}
else{
$error = true;
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact</title>
<link rel="icon" type="image/png" href="images/<?php echo $icon; ?>" />
<link rel="stylesheet" href="sign_up.css">
</head>
<body>
<?php include "navbar.php"; ?>
<div id="container">
<?php
if($success == true){ ?>
<span id="success">Message sent successfully!<b onclick="remove(this)">×</b></span>
<?php }
if($error == true){ ?>
<span id="error">Something went wrong...<b onclick="remove(this)">×</b></span>
<?php }
?>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
<h2>Contact Us</h2>
<div class="input">
<label for="fname">Full Name</label>
<input type="text" id="fname" name="fname" autofocus autocomplete="off" required>
</div>
<div class="input">
<label for="phone">Phone</label>
<input type="tel" id="phone" name="phone" pattern='[0-9]{10}' autofocus autocomplete="off" required>
</div>
<div class="input">
<label for="email">Email</label>
<input type="email" id="email" name="email" autofocus autocomplete="off" required>
</div>
<div class="input">
<label for="address">Address</label>
<input type="text" name="address" id="address" autofocus autocomplete="off" required>
</div>
<div class="input">
<label for="message">Message</label>
<textarea name="message" id="message" cols="30" rows="10" required autofocus autocomplete="off"></textarea>
</div>
<div class="input" id="field5">
<button type="submit" name="submit" id="btn">Submit</button>
</div>
</form>
</div>
<script src="sign_up.js"></script>
</body>
</html>