-
Notifications
You must be signed in to change notification settings - Fork 0
/
Contact.php
136 lines (108 loc) · 3.96 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
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
<!-- Nicholas MacFarland
03/04/20
CSIS 474-B01
Contact Page
Description:
This is the "Contact" page of the site that lets
the customer send feedback and send questions if
the customer has any.
-->
<?php
session_start(); /* Starts the session */
if (!isset($_SESSION['username']))
{
if (!isset($_SESSION['password']))
{
header("Refresh:5;url=LogIn.php");
echo "<h1>Please go and log in first before entering site, <br> you will be redirected in 5 seconds to the log-in screen.</h1>";
exit;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="TennisHubb.css">
<link rel="stylesheet" type="text/css" href="Top_Menu_Navigation.css">
<div class="title">
<title>
TENNIS HUBB SITE
</title>
CONTACT US
</div>
</head>
<hr>
<div class="topnav">
<a href="index.php">Home</a>
<a href="Shop.php">Shop</a>
<a class="active" href="#contact">Contact</a>
<a href="Shopping_Cart.php">Shopping Cart</a>
<a href="logout.php" onclick=" return confirm('Are You sure you want to logout?');">Log-out</a>
</div>
<hr>
<body>
<?php
echo <<< Contact_Info
<form action="" method="post">
<div class="contactInfo">
<h2>
Please Enter Contact Information Below:
</h2>
Enter First Name:
<br>
<input name="fname" type="text" required=""/>
<br><br>
Enter Last Name:
<br>
<input name="lname" type="text" required=""/>
<br><br>
Preferred Email Address:
<br>
<input name="email" type="email" required=""/>
<br><br>
Type in message below:
<br>
<input style="height: 200px;width:250px;" type="text" name="feedback" maxlength="500" required = "">
<br><br>
<input name="submit_contact_info" type="submit" value="Submit Info" />
<br><br>
</div>
</form>
Contact_Info;
if (isset( $_POST['submit_contact_info']))
{
include "dblogin.php"; //Connecting to database here
if(isset($_POST['fname'])) $First_Name = $_POST['fname']; //gets the fname array
else $First_Name = '';
if(isset($_POST['lname'])) $Last_Name = $_POST['lname']; //gets the lname array
else $Last_Name = '';
if(isset($_POST['email'])) $Email = $_POST['email']; //gets the email array
else $Email = '';
if(isset($_POST['feedback'])) $Feedback = $_POST['feedback']; //gets the feedback array
else $Feedback = '';
if ($First_Name != '' && $Last_Name != '' && $Email != '' && $Feedback != '')
{
$First_Name = mysqli_real_escape_string($mysqli_link, $First_Name);
$Last_Name = mysqli_real_escape_string($mysqli_link, $Last_Name);
$Email = mysqli_real_escape_string($mysqli_link, $Email);
$Feedback = mysqli_real_escape_string($mysqli_link, $Feedback);
$member_id_result = mysqli_query($mysqli_link,"select Member_ID from member_table where Fname = '$First_Name'
and Lname = '$Last_Name'");
}
while ($row = mysqli_fetch_array($member_id_result,MYSQLI_ASSOC))
{
//if statement not binded die saying oh no!
$add_contact_info_stmt = mysqli_prepare($mysqli_link,"insert into contact_table(member_id,firstname,lastname,Email_Address,Feedback) values (?,?,?,?,?)");
if (! $add_contact_info_stmt->bind_param('sssss',$row["Member_ID"],$First_Name, $Last_Name, $Email, $Feedback)) die ('oh, no!');
if (! $add_contact_info_stmt ->execute()) die ('did not execute!'); //executing here, if not executed, it dies
}
//closing the statement
mysqli_close($mysqli_link);
echo "<meta http-equiv='refresh' content='1;url=Contact_Confirmation.php'>";
}
?>
</body>
<?php
include "footer.php";
?>
</html>