Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/projekt/snake_oil_seller/php/
about_us.php
add_to_cart.php
buy_cart.php
config.php
contact.php
create_products.php
create_tables.php
dbconnection.php
delete_tables.php
entry.php
header.php
insert_posts.php
log_in.php
log_out.php
main.php
my_account.php
shop.php
shop_item.php
shopping_cart.php
sign_in.php
title_card.php
user_verified.php
verify_page.php
add_to_cart.php
20 lines UTF-8 Windows (CRLF)
<?php
session_start();
// Lägger till produkt i kundvagnen
if (!isset($_SESSION["cart"])) {
$_SESSION["cart"] = [];
}
if (isset($_POST["product_id"])) {
$product_id = $_POST["product_id"];
if (isset($_SESSION["cart"][$product_id])) {
$_SESSION["cart"][$product_id]++;
} else {
$_SESSION["cart"][$product_id] = 1;
}
echo "ok";
}
?>