-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainpage.php
154 lines (124 loc) · 5.12 KB
/
mainpage.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<html>
<head>
<title>Books Worldwide</title>
<link rel="stylesheet" href="mainstyle.css">
</head>
<body>
<table class="thetable">
<tr>
<th><h1>Welcome to Books Worldwide</h1></th>
<th>
<?php
session_start();
include("connectiondb.php");
$cN = $_SESSION['emailOF'];
$cNP = $_SESSION['passwordOF'];
$sql = "SELECT * FROM Customers c, Contact_Details f, Email z WHERE
c.ContactID = f.ContactID AND f.ContactID = z.ContactID AND c.Cpassword='$cNP' AND z.EmailAddress = '$cN'";
$result = mysqli_query($conn, $sql);
if ($row = mysqli_fetch_assoc($result)) {
echo "Welcome, {$row['FirstName']}";
}
$sql2 = "SELECT c.IfAdmin FROM Customers c, Contact_Details f, Email z WHERE
c.ContactID = f.ContactID AND f.ContactID = z.ContactID AND c.Cpassword='$cNP' AND z.EmailAddress = '$cN'";
$result2 = mysqli_query($conn, $sql2);
if ($row = mysqli_fetch_assoc($result2)) {
if ($row['IfAdmin'] == 0){
$admin = False;
}else{
$admin = True;
}
}
echo "</th>";
if ($admin == 0){
echo "<th><p><a href='cPage.php'>Your Account</a> </p></th>";
}else{
echo "<th><p><a href='admin.php'>Your Account</a> </p></th>";
}
?>
<th><p><a href="shoppingCart.php">Shopping Cart</a> </p></th>
</tr>
</table>
<?php
include("connectiondb.php");
if(mysqli_connect_error()){
die('Connect Error('.mysqli_connect_error().')'.mysqli_connect_error());
}
$sqlget = "SELECT * FROM Books";
$sqldata = mysqli_query($conn, $sqlget) or die('Error');
echo "<table class = 'phptable'>";
echo "<tr><th>Book Titles</th></tr>";
while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) {
echo '<tr><th><a href="bookpage.php?title='.$row['Title'].'">'.$row['Title'].'<a/></tr></th>';
}
echo "</table>";
$sqlget2 = "SELECT * FROM `Book_Categories`";
$sqldata2 = mysqli_query($conn, $sqlget2) or die('Error');
echo "<table class = 'genretable'>";
echo "<tr><th>Search by Book Genres</th></tr>";
while($row = mysqli_fetch_array($sqldata2, MYSQLI_ASSOC)) {
echo '<tr><th><a href="filter.php?Filer='.$row['CategoryDescription'].'">'.$row['CategoryDescription'].'<a/></tr></th>';
}
echo "</table>";
?>
<div class = "mainintro">
<h2> What is Books Worldwide? </h2>
<div class = "whats">
<p> Books Worldwide© is the ultimate online way to get your books! <br>
We offer 24/7 customer support, money back guaranteed, <br>
Worldwide free shipping, and many other things. </p>
</div>
<h2> Why should you use Books WorldWide? </h2>
<div class = "why">
<p> Books Worldwide© offers some of the best selection of books <br>
available to the public. Not only that but it is easy to use, and <br>
easy to search for books. </p>
</div>
<h2> Whats the catch? Is it that easy?</h2>
<div class = "catch">
<p> There is no catch what so ever! We take customer satisfaction as <br>
our number 1 priority. NOW GET SHOPPING!! </p>
</div>
</div>
<div class = "sign-up">
<p> Already a member? <a href="login.php">Sign in</a> </p>
<p> Want to sign up?? <a href="register.php">Sign up</a> </p>
</div>
<form method = "post">
<table>
Find Book
<th>Search Title <input type = "text" name = "FindBook" value = ""></a></th>
<th><p><a><input type= "submit" name = "Book" value = "Find Book"/></a></p></th>
</table>
</form>
<?php
include("connectiondb.php");
if (isset($_POST['Book'])){
$searchfbook = $_POST['FindBook'];
$searchfbook = preg_replace("#[^0-9 a-z]#i", "", $searchfbook);
$sqlBook = "SELECT * FROM books WHERE Title LIKE '%$searchfbook%'";
$query = mysqli_query($conn, $sqlBook) or die("Could not search");
$count = mysqli_num_rows($query);
if($count == 0){
print("There was no search results");
}else {
echo "<table border =1>";
echo"<tr><td>Book</td></tr>";
while($row = mysqli_fetch_array($query)){
echo"<tr><td>{$row['Title']}</td></tr>";
}
echo"</table>";
}
}
echo "</table>";
$sqlget2 = "SELECT * FROM `Author`";
$sqldata2 = mysqli_query($conn, $sqlget2) or die('Error');
echo "<table class = 'Authortable'>";
echo "<tr><th>Search by Author</th></tr>";
while($row = mysqli_fetch_array($sqldata2, MYSQLI_ASSOC)) {
echo '<tr><th><a href="filter.php?Au='.$row['FirstName'].' '.$row['LastName'].'">'.$row['FirstName'].' '.$row['LastName'].'<a/></tr></th>';
}
echo "</table>";
?>
</body>
</html>