This repository has been archived by the owner on Feb 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateReview.php
executable file
·166 lines (138 loc) · 7.59 KB
/
createReview.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
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php include "session.php"; ?>
<!--createReview.php allows a customer to submit a review for a product. The review consists of the a rating from 1-5 and a written opinion. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<title>Front Page</title>
<!--Styles-->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 15px;
padding-bottom: 20px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
<!-- Icons -->
<link rel="shortcut icon" href="http://twitter.github.com/bootstrap/assets/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-57-precomposed.png">
</head>
<body>
<!--Start of Center Section-->
<div id="center-section">
<!--Start of Navigation Bar-->
<div class="navbar navbar-inverse ">
<div class="navbar-inner">
<div class="container-nav">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<!--Links to Account Login and Cart-->
<div class="nav-collapse collapse">
<p class="navbar-text pull-right">
<ul class="nav pull-right">
<?php include './models/Account.php';
$db = new DatabaseLink();
$a = Account::dbGet($_SESSION['accountId'], $db);
if ($a == false) {
echo("<a class=\"brand\" href=\"login.php\">Login/Create Account</a>");
} else {
echo("<a class=\"brand\" href=\"accountmgr.php\">Hello, " . $a->fields['first_name'] . "!</a>");
}
?>
<a class="brand" href="mycart.php">My Cart</a>
</ul>
</p>
</div>
<!--Search Bar-->
<form class="form-search" action="search.php" method="post" name="Search">
<div style="text-align:left">
<input type="text" name="fsearch" maxlength="100" class="span6 input-large search-query">
<button type="submit" class="btn">Search</button>
</div>
</form><!--End of Search Bar-->
</div>
</div>
</div><!--End of Navigation Bar-->
<!--Start of the Center Section below the Navigation Bar-->
<div class="container-center">
<div class="row-fluid">
<!--Logo Here-->
<a class="brand" href="index.php"> <img src="assets/img/logo.png"></a>
</div>
<!--Start of Sidebar-->
<div class="row-fluid">
<div class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Product Categories</li>
<?php include 'sidebar.php';?>
</ul>
</div><!--End of Sidebar-->
</div><!--Span-->
<!--Start of Main Section-->
<div class="span9">
<div class="container-main">
<form action="reviewProcessing.php" method="post" name="Processing">
<?php
if(isset($_GET['product_id']))
{
/* Posts the customer's account id for processing */
echo("<input type=\"hidden\" name=\"accountId\" value=\"" . $_SESSION['accountId'] . "\"><br>");
/* Connect to database */
$db = new DatabaseLink();
$con = $db->connection;
$query = "";
$row = array();
/* Query for the name of the product being reviewed */
$query = ("SELECT name FROM `products` WHERE id =" . $_GET['product_id']);
$result = mysql_query($query, $con) or die("Could not execute query '$query'");
$row = mysql_fetch_array($result);
echo("<h3>Write your review</h3><br>");
/* Print the name of the product being reviewed and post the product's id for processing */
echo("<b>Product:</b> " . $row[0] . "<br>");
echo("<input type=\"hidden\" name=\"productId\" value=\"" . $_GET['product_id'] . "\"><br>");
/* Generates a dropdown box of ratings from 1 to 5 */
echo("<b>How would you rate this product: </b>");
echo("<select style=\"width:60px;\" name=rating>");
for($i = 1; $i <= 5; $i++)
{
echo("<option value=\"" . $i . "\">" . $i ."</option>");
}
echo("</select> out of 5 <br><br>");
/* Generates a text box for the customer to type their opinion about the product */
echo("<b>What do you think of this product?</b><br>");
echo("<textarea style=\"width:750px; height: 200px;\" name=\"review\" maxlength=\"3000\"></textarea><br>");
/* generates a submit button to submit the review for processing */
echo("<input type=\"submit\" value=\"Submit Review\">");
$db->disconnect();
}
?>
</form>
</div><!--End of Main Section-->
</div><!--Span-->
</div><!--End of row containing sidebar and main section-->
<hr><!--Breakline before Footer-->
<!--Footer-->
<footer>
<p><a href="#">Contact Us</a></p>
</footer>
</div><!--End of the Center Section below the Navigation Bar-->
</div><!--End of Center Section-->
<!-- Javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery-1.8.2.min.js"></script>
<script src="assets/js/bootstrap.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
</body></html>