-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact.php
More file actions
167 lines (140 loc) · 5.68 KB
/
contact.php
File metadata and controls
167 lines (140 loc) · 5.68 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
session_start(); // Start the session.
$page_title = 'Welcome to Bel\'s Resturant| Contact Us';
include ('includes/header.html');
// Check if the form has been submitted:
if (isset($_POST['submitted'])) {
require_once ('../mysqli_connect.php'); // Connect to the db.
$errors = array(); // Initialize an error array.
// Check for a first name:
if (empty($_POST['first_name'])) {
$errors[] = 'You forgot to enter your first name.';
} else {
$fn = mysqli_real_escape_string($dbc, trim($_POST['first_name']));
}
// Check for a last name:
if (empty($_POST['last_name'])) {
$errors[] = 'You forgot to enter your last name.';
} else {
$ln = mysqli_real_escape_string($dbc, trim($_POST['last_name']));
}
// Check for an email address:
if (empty($_POST['email'])) {
$errors[] = 'You forgot to enter your email address.';
} else {
$e = mysqli_real_escape_string($dbc, trim($_POST['email']));
}
// Check for message:
if (empty($_POST['message'])) {
$errors[] = 'You forgot to enter your your message.';
} else {
$m = mysqli_real_escape_string($dbc, trim($_POST['message']));
}
if (empty($errors)) { // If everything's OK.
// Register the user in the database...
// Make the query:
$q = "INSERT INTO contactus (first_name, last_name, email, message, date_created) VALUES ('$fn', '$ln', '$e', '$m', NOW() )";
$r = @mysqli_query ($dbc, $q); // Run the query.
if ($r) { // If it ran OK.
// Print a message:
echo ' <div id="content">
<div class="container">
<div class="inside">
<!-- box begin -->
<div class="box alt">
<div class="left-top-corner">
<div class="right-top-corner">
<div class="border-top"></div>
</div>
</div>
<div class="border-left">
<div class="border-right">
<div class="inner">
<div class="wrapper">
<dl class="special fright">
<dt>Special</dt>
<dd><img alt="" src="images/1page-img1.jpg" /><span>12.95</span></dd>
<dd><img alt="" src="images/1page-img2.jpg" /><span>12.95</span></dd>
</dl>
<h1>Thank you!</h1>
<p></p>
<p>Your message was sent. You will recieved a response within the next 48hrs!</p><p><br /></p>
</div>
</div>
</div>
<div class="left-bot-corner">
<div class="right-bot-corner">
<div class="border-bot"></div>
</div>
</div>
</div>
</div>
</div>
</div>
';
} else { // If it did not run OK.
// Public message:
echo '<h1>System Error</h1>
<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>';
// Debugging message:
echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
} // End of if ($r) IF.
mysqli_close($dbc); // Close the database connection.
// Include the footer and quit the script:
include ('includes/footer.html');
exit();
} else { // Report the errors.
echo '<h1>Error!</h1>
<p class="error">The following error(s) occurred:<br />';
foreach ($errors as $msg) { // Print each error.
echo " - $msg<br />\n";
}
echo '</p><p>Please try again.</p><p><br /></p>';
} // End of if (empty($errors)) IF.
mysqli_close($dbc); // Close the database connection.
} // End of the main Submit conditional.
?>
<!-- content -->
<div id="content">
<div class="container">
<div class="inside">
<!-- box begin -->
<div class="box alt">
<div class="left-top-corner">
<div class="right-top-corner">
<div class="border-top"></div>
</div>
</div>
<div class="border-left">
<div class="border-right">
<div class="inner">
<h2>Contact Us</h2>
<br></b><strong>Our Mailing address</strong></b></br>
<br>3410 Taft Blvd</br>
Wichita Falls, Texas 76308<br><a>940-397-4000</a></br>
<p></p><br>
<form id="contacts-form" action="contact.php" method="post">
<fieldset>
<div class="field"><label>First Name:</label><input type="text" name="first_name" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>"/></div>
<div class="field"><label>Last Name:</label><input type="text" name="last_name"value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>"/></div>
<div class="field"><label>E-mail:</label><input type="text" name="email" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>"/></div>
<div class="field"><label>Message:</label><textarea cols="" rows="" name="message" value="<?php if (isset($_POST['message'])) echo $_POST['message']; ?>"></textarea></div>
<div class="alignright"><input type="submit" name="submit" value="Send Your Message!" /></a></div>
<input type="hidden" name="submitted" value="TRUE" />
</form>
</div>
</div>
</div>
<div class="left-bot-corner">
<div class="right-bot-corner">
<div class="border-bot"></div>
</div>
</div>
</div>
<!-- box end -->
</div>
</div>
</div>
<?php
include ('includes/footer.html');
?>