window.location.href = "../index.php";'; //redirect
}
require_once '../../functions.php';
$pageContent = '
Add auction
';
require '../../layout.php';
if (isset($_POST['submit'])) {
if(imageUpload($_POST['title'].$_POST['endDate'])) { //if the image upload is successful add auction
$user = getFirstAllMatches('users', 'user_id', $_SESSION['loggedin']); //get the first match of an all column query
$pdo = startDB();
$stmt = $pdo->prepare('INSERT INTO auction (title, description, endDate, categoryId, email, imgUrl)
VALUES (:title, :description, :endDate, :categoryID, :email, :imgUrl)');
$values = [
'title' => $_POST['title'],
'description' => $_POST['description'],
'endDate' => $_POST['endDate'],
'categoryID' => intval($_POST['category']),
'email' => $user['email'],
'imgUrl' => 'public/images/auctions/'.$_POST['title'].$_POST['endDate']
];
$stmt->execute($values);
echo 'Successful Post
';
}
}
?>