forked from dmkato/halfWoundMusic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·73 lines (61 loc) · 2.37 KB
/
index.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
<?php
include 'php/config.php';
$pageTitle = "shop";
include "php/header.php";
?>
<div id="contentBlock" class="container">
<div class="row">
<?php
// Create column
if ($username == "Guest") {
echo "<div class='productContainer col-md-9'>";
} else {
echo "<div class='productContainer col-md-12'>";
}
// Create connection
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
// Check connection
if (!$conn)
die("Connection failed: " . mysqli_connect_error());
$sql = "SELECT productID, name, description, price, brandName FROM Product WHERE stock > 0";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)) {
$imageID = (string) $row["productID"];
$imageLink = "images/".$imageID.".jpeg";
echo "<div class='centered'>";
echo "<div class='productRow row'>";
echo "<div class='col-md-3 text-center'>";
echo "<img src=".$imageLink." alt='Cover' style='width:100%; height:auto;'>";
echo "</div>";
echo "<div class='col-md-9'>";
echo "<a href='".$directory."/php/product.php?productID=".$imageID."'><h3> ".$row["brandName"]." ".$row["name"]."</h3>";
echo " $".$row["price"]."</a>";
echo "</div>";
echo "</div><br>";
}
mysqli_close($conn);
echo "<br><br></div></div></div>";
if ($username == "Guest") {
echo "<div id='formContainer' class='col-md-3'>
<form class='Form' action = 'php/loginProcess.php' method='post' onsubmit='return formvalidate(this);'>
<h3>Login</h3>
<div id='emailField' class='form-group'>
<input type='email' name='user' class='form-control' id='email' placeholder='Email'>
</div>
<div id='passwordField' class='form-group'>
<input type='password' name='password' class='form-control' id='userpassword' placeholder='Password'>
</div>
<a href='".$directory."/php/signup.php'>Don't Have an account? Sign up!</a>
<div>
<input id='submitButton' type='submit' class='btn btn-default'>
<span id='ajaxStatus'></span>
</div>
</form>
</div>";
}
echo "</div>";
include 'php/footer.php';
?>
<br><br><br>
</body>
</html>