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
admin.php
buy_cart.php
config.php
contact.php
create_products.php
create_tables.php
createtable.php
dbconnection.php
delete_post.php
delete_tables.php
deletepost.php
deletetable.php
entry.php
header.php
insert_posts.php
insertposts.php
leaderboard.php
log_in.php
log_out.php
main.php
my_account.php
question_maker.php
quiz_form.php
quiz_list.php
quiz_maker.php
result.php
select_posts.php
selectposts.php
shop.php
shop_item.php
shopping_cart.php
sign_in.php
title_card.php
update_posts.php
updateposts.php
user_verified.php
verify_page.php
header.php
273 lines UTF-8 Windows (CRLF)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
<?php
/** @var PDO $dbconn*/
include ("dbconnection.php");
// Kollar och ändrar vald flik beroende på vald sida
$currentPage = basename($_SERVER["PHP_SELF"]);
// Kollar om man är admin för att visa "create_products
if ($is_logged_in) {
$sql = $dbconn->prepare("SELECT usertype FROM users WHERE username = ?");
$sql->execute([$_SESSION["username"]]);
$result = $sql->fetch(PDO::FETCH_ASSOC);
if ($result["usertype"] == "admin") {
$is_admin = true;
} else {
$is_admin = false;
}
}
if ($is_logged_in && $is_admin) {
// Inloggad - "My account" länken finns
if ($currentPage === "main.php") {
echo '
<div id="rubrics">
<a href="main.php"style="font-weight: bold; font-size: 1.5em;">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="create_products.php">Create products</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'shop.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php" style="font-weight: bold; font-size: 1.5em;">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="create_products.php">Create products</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'about_us.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php" style="font-weight: bold; font-size: 1.5em;">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="create_products.php">Create products</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'contact.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php" style="font-weight: bold; font-size: 1.5em;">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="create_products.php">Create products</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'shopping_cart.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php" style="font-weight: bold; font-size: 1.5em;">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="create_products.php">Create products</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'my_account.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php" style="font-weight: bold; font-size: 1.5em;">My account</a>
<a href="create_products.php">Create products</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'shop_item.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php"">My account</a>
<a href="create_products.php">Create products</a>
<a href="log_out.php">Log out</a>
</div>';
}
} else if ($is_logged_in && !$is_admin) {
// Inloggad med vanlig user
if ($currentPage === "main.php") {
echo '
<div id="rubrics">
<a href="main.php"style="font-weight: bold; font-size: 1.5em;">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'shop.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php" style="font-weight: bold; font-size: 1.5em;">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'about_us.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php" style="font-weight: bold; font-size: 1.5em;">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'contact.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php" style="font-weight: bold; font-size: 1.5em;">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'shopping_cart.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php" style="font-weight: bold; font-size: 1.5em;">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'my_account.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="log_in.php">Log in</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'shop_item.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="my_account.php">My account</a>
<a href="log_out.php">Log out</a>
</div>';
}
} else {
// Inte inloggad - My account blir till "log in"
if ($currentPage === "main.php") {
echo '
<div id="rubrics">
<a href="main.php"style="font-weight: bold; font-size: 1.5em;">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="log_in.php">Log in</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'shop.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php" style="font-weight: bold; font-size: 1.5em;">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="log_in.php">Log in</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'about_us.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php" style="font-weight: bold; font-size: 1.5em;">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="log_in.php">Log in</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'contact.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php" style="font-weight: bold; font-size: 1.5em;">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="log_in.php">Log in</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'shopping_cart.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php" style="font-weight: bold; font-size: 1.5em;">Shopping cart</a>
<a href="log_in.php">Log in</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'my_account.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="log_in.php" style="font-weight: bold; font-size: 1.5em;">Log in</a>
<a href="log_out.php">Log out</a>
</div>';
} else if ($currentPage === 'shop_item.php') {
echo '
<div id="rubrics">
<a href="main.php">Main</a>
<a href="shop.php">Shop</a>
<a href="about_us.php">About us</a>
<a href="contact.php">Contact</a>
<a href="shopping_cart.php">Shopping cart</a>
<a href="log_in.php">Log in</a>
<a href="log_out.php">Log out</a>
</div>';
}
}
?>