Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/exercises/projekt/

changeowned.php
classes/
createcard.php
database.php
forgot.php
incl/
index.php
leaderboard.php
lineup.php
login.php
logout.php
newpass.php
otherlineup.php
playerinfo.php
projekt.zip
skapatabeller.php
verify.php

changeowned.php

60 lines UTF-8 Windows (CRLF)
<?php
$title 
"Ändra samling";
$pageId "changeowned";
$pageStyle '
figure { 
 border-radius: 10px;
 border-color:#333;
 box-shadow: 10px 10px 5px #888;
}'
;
require_once(
"classes/collection.php");
$changecollection = new Collection($dbconn);
include(
"incl/protected.php");
include(
"incl/header.php");
$userid $_SESSION['userid'];
if (isset(
$_POST['submit'])) {
    foreach (
$_POST as $playerid => $value) {
        if (
$value === 'on') {
            
$playerid htmlspecialchars($playeridENT_QUOTES,'UTF-8');
            
$changecollection->removefromcollection($userid$playerid);
        } else {
            continue;
        }
    }
    
header("Location: " $_SERVER['REQUEST_URI']); // Redirect to the same page
    
exit;
}
if (isset(
$_POST['add'])) {
    foreach (
$_POST as $playerid => $value) {
        if (
$value === 'on') {
            
$playerid htmlspecialchars($playeridENT_QUOTES,'UTF-8');
            
$changecollection->addtocollection($playerid$userid);
        }
    }
    
header("Location: " $_SERVER['REQUEST_URI']); // Redirect to the same page
    
exit;
}
?>
<main>
    <section>
        <article>
            <h2>Ta bort spelare från samling</h2>
            <form action="" method="post">
                <?php
                $changecollection
->showownedplayers($userid);
                
?>
                <button type="submit" name="submit">Ta bort</button>
            </form>
        </article>
        <article>
            <h2>Lägg till spelare till samling</h2>
            <form action="" method="post">
                <?php
                $changecollection
->show_notownedplayers($userid);
                
?>
                <button type="submit" name="add">Lägg till</button>
            </form>
        </article>
    </section>
</main>
<?php include("incl/footer.php"); ?>