From 8e497df9b5325271713b201be71ccee98c4d930f Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Sun, 20 Nov 2022 14:10:05 +0000 Subject: [PATCH] added addAuction.php --- public/account/addAuction.php | 51 +++++++++++++++++++++++++++++++++++ public/account/login.php | 2 +- public/account/register.php | 4 +-- public/index.php | 3 ++- 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/public/account/addAuction.php b/public/account/addAuction.php index e69de29..9d4a515 100644 --- a/public/account/addAuction.php +++ b/public/account/addAuction.php @@ -0,0 +1,51 @@ +window.location.href = "../index.php";'; +} + +require_once '../../functions.php'; +$pdo = startDB(); + +$pageContent = '

Add auction

+
+ + + + + +
'; +require '../../layout.php'; + +if (isset($_POST['submit'])) { + $stmt = $pdo->prepare('SELECT * FROM users WHERE user_id = :user_id'); + $values = [ + 'user_id' => $_SESSION['loggedin'] + ]; + $stmt->execute($values); + $user = $stmt->fetch(); + + + $stmt = $pdo->prepare('INSERT INTO auction (title, description, endDate, categoryId, email) VALUES (:title, :description, :endDate, :categoryID, :email)'); + $values = [ + 'title' => $_POST['title'], + 'description' => $_POST['description'], + 'endDate' => $_POST['endDate'], + 'categoryId' => $_POST['category'], + 'email' => $user['email'] + ]; + $stmt->execute($values); + echo '

Successful Post

'; +} + +function populateCats() { + $cats = fetchCats(); + $output = ''; + foreach ($cats as &$cat) { + $output .= ''; + } + return $output; +} \ No newline at end of file diff --git a/public/account/login.php b/public/account/login.php index a81a3c1..844951f 100644 --- a/public/account/login.php +++ b/public/account/login.php @@ -4,7 +4,7 @@ $pageTitle = 'iBuy - Login'; $pageContent = '

Don\'t have an account?Click here to register

Login

- +
'; diff --git a/public/account/register.php b/public/account/register.php index 55f6e67..27adf79 100644 --- a/public/account/register.php +++ b/public/account/register.php @@ -22,8 +22,8 @@ $pageContent = '

Already have an account?Click here to L

- - + + '; diff --git a/public/index.php b/public/index.php index 39516be..b45cb8c 100644 --- a/public/index.php +++ b/public/index.php @@ -12,7 +12,8 @@ else { } require_once '../functions.php'; -$pageContent = '

'.$pageHeading.'

+$pageContent = '
post auction +

'.$pageHeading.'

'; require '../layout.php';