-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcarrelloLogica.php
30 lines (25 loc) · 1.12 KB
/
carrelloLogica.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
<?php
require_once "connector.php";
if(isset($_GET['buy']) && $dbh->existCart($_SESSION['username'])){
$templateParams["buy"] = "COMPLIMENTI! Acquisto effetuato con successo!";
$dbh->buy($_SESSION['username']);
}
if(isSellerLoggedIn()){
$templateParams["errore"] = "I venditori non possono fare acquisti!";
}elseif(!isSellerLoggedIn() && !isUserLoggedIn()){
$templateParams["errore"] = "Accedi per effettuare acquisti!";
}
if (isUserLoggedIn() && isset($_GET['pAdd'])) {
$dbh->addToCart($_SESSION['username'], (int)$_GET['pAdd']);
header("location: carrelloLogica.php");
}elseif(isUserLoggedIn() && isset($_GET['pRemove'])){
$dbh->removeOneFromCart((int)$_GET['pRemove'], $_SESSION['username']);
header("location: carrelloLogica.php");
}
if(isUserLoggedIn()){
$dbh->isCartEmpty($_SESSION['username']);
$templateParams["cartProduct"] = $dbh->getCart($_SESSION['username']);
}
$templateParams["Pagina"] = "./TEMPLATE/carrello.php";
require "TEMPLATE/base.php";
?>