began populating listings from db
This commit is contained in:
parent
dc73e566f6
commit
978753bfae
|
|
@ -23,7 +23,7 @@ if (isset($_POST['submit'])) {
|
||||||
$user = $stmt->fetch();
|
$user = $stmt->fetch();
|
||||||
if (password_verify($_POST['password'], $user['password'])) {
|
if (password_verify($_POST['password'], $user['password'])) {
|
||||||
$_SESSION['loggedin'] = $user['user_id'];
|
$_SESSION['loggedin'] = $user['user_id'];
|
||||||
echo'<p>Successful login</p>';
|
echo'<script>window.location.href = "../index.php";</script>';
|
||||||
if ($user['admin'] === 'y') {
|
if ($user['admin'] === 'y') {
|
||||||
$_SESSION['loggedin'] = 'y';
|
$_SESSION['loggedin'] = 'y';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function addUser() {
|
function addUser() {
|
||||||
$server = 'mysql';
|
$server = 'mysql';
|
||||||
$username = 'student';
|
$username = 'student';
|
||||||
|
|
@ -31,7 +30,6 @@ $pageContent = '<p>Already have an account?<a href=\'login.php\'>Click here to L
|
||||||
</form>';
|
</form>';
|
||||||
require '../../layout.php';
|
require '../../layout.php';
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
addUser();
|
addUser();
|
||||||
echo '<p>Successful account creation</p>';
|
echo '<p>Successful account creation</p>';
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
//Listing display page. Display the 10 auctions finishing soonest
|
//Listing display page. Display the 10 auctions finishing soonest
|
||||||
//Can be used for index, search page, and category listing
|
//Can be used for index, search page, and category listing
|
||||||
|
|
||||||
$pageTitle = 'iBuy - Home';
|
$pageTitle = 'iBuy - Home';
|
||||||
|
|
||||||
if (isset($_GET['pageHeading'])) {
|
if (isset($_GET['pageHeading'])) {
|
||||||
|
|
@ -15,6 +14,7 @@ $pageContent = '<h1>'.$pageHeading.'</h1>
|
||||||
<ul class="productList">'.populateList($pageHeading).'</ul>';
|
<ul class="productList">'.populateList($pageHeading).'</ul>';
|
||||||
require '../layout.php';
|
require '../layout.php';
|
||||||
|
|
||||||
|
|
||||||
function populateList($category) { //TODO: This will need to be updated to populate from the database
|
function populateList($category) { //TODO: This will need to be updated to populate from the database
|
||||||
$output = '';
|
$output = '';
|
||||||
$server = 'mysql';
|
$server = 'mysql';
|
||||||
|
|
@ -24,7 +24,7 @@ function populateList($category) { //TODO: This will need to be updated to popul
|
||||||
$pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password);
|
$pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password);
|
||||||
|
|
||||||
if ($category === 'Latest Listings') {
|
if ($category === 'Latest Listings') {
|
||||||
$stmt = $pdo->prepare('SELECT * FROM listings WHERE listing_deadline > "'. date("Y-m-d h:i:s"). '" ORDER BY listing_deadline DESC');
|
$stmt = $pdo->prepare('SELECT * FROM listings WHERE listing_deadline > "'. date("Y-m-d H:i:s"). '" ORDER BY listing_deadline DESC');
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$listings = $stmt->fetchAll();
|
$listings = $stmt->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,40 @@
|
||||||
$pageTitle = 'iBuy - Product Listing';
|
$pageTitle = 'iBuy - Product Listing';
|
||||||
//TODO: have page populate information based on listing in the database
|
//TODO: have page populate information based on listing in the database
|
||||||
$pageContent = '<h1>Product Page</h1>
|
$pageContent = '<h1>Product Page</h1>
|
||||||
<article class="product">
|
<article class="product">'. populateContent() .'</article>';
|
||||||
|
|
||||||
<img src="product.png" alt="product name">
|
require '../layout.php';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function populateContent() {
|
||||||
|
$server = 'mysql';
|
||||||
|
$username = 'student';
|
||||||
|
$password = 'student';
|
||||||
|
$schema = 'ibuy';
|
||||||
|
$pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password);
|
||||||
|
$stmt = $pdo->prepare('SELECT * FROM listings WHERE listing_id= :listing_id');
|
||||||
|
$values = [
|
||||||
|
'listing_id' => $_GET['listing_id']
|
||||||
|
];
|
||||||
|
|
||||||
|
$stmt->execute($values);
|
||||||
|
$listing = $stmt->fetch();
|
||||||
|
|
||||||
|
$output = ' <img src="product.png" alt="product name">
|
||||||
<section class="details">
|
<section class="details">
|
||||||
<h2>Product name</h2>
|
<h2>'. $listing['listing_name'] .'</h2>
|
||||||
<h3>Product category</h3>
|
<h3>'. $listing['listing_category'] .'</h3>
|
||||||
<p>Auction created by <a href="#">User.Name</a></p>
|
<p>Auction created by <a href="#">User.Name</a></p>
|
||||||
<p class="price">Current bid: £123.45</p>
|
<p class="price">Current bid: £123.45</p>
|
||||||
<time>Time left: 8 hours 3 minutes</time>
|
<time>Time left:'. (strtotime($listing['listing_deadline']) - strtotime(date('Y-m-d H:i:s')))/60 .'</time>
|
||||||
<form action="#" class="bid">
|
<form action="#" class="bid">
|
||||||
<input type="text" name="bid" placeholder="Enter bid amount" />
|
<input type="text" name="bid" placeholder="Enter bid amount" />
|
||||||
<input type="submit" value="Place bid" />
|
<input type="submit" value="Place bid" />
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
<section class="description">
|
<section class="description">
|
||||||
<p>
|
<p>'. $listing['listing_description'] .'</p>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sodales ornare purus, non laoreet dolor sagittis id. Vestibulum lobortis laoreet nibh, eu luctus purus volutpat sit amet. Proin nec iaculis nulla. Vivamus nec tempus quam, sed dapibus massa. Etiam metus nunc, cursus vitae ex nec, scelerisque dapibus eros. Donec ac diam a ipsum accumsan aliquet non quis orci. Etiam in sapien non erat dapibus rhoncus porta at lorem. Suspendisse est urna, egestas ut purus quis, facilisis porta tellus. Pellentesque luctus dolor ut quam luctus, nec porttitor risus dictum. Aliquam sed arcu vehicula, tempor velit consectetur, feugiat mauris. Sed non pellentesque quam. Integer in tempus enim.</p>
|
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -37,7 +54,8 @@ $pageContent = '<h1>Product Page</h1>
|
||||||
|
|
||||||
<input type="submit" name="submit" value="Add Review" />
|
<input type="submit" name="submit" value="Add Review" />
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>';
|
||||||
</article>';
|
|
||||||
require '../layout.php'
|
return $output;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue