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

skapatabeller.php

100 lines ASCII Windows (CRLF)
<!-- createtable.php -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Create</title>
</head>

<body>
<?php
include ('incl/dbconnection.php');
try {

    
// sql to create table
    
$sql "CREATE TABLE projektusers (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
    name VARCHAR(30) NOT NULL,
    email VARCHAR(30) NOT NULL,
    password VARCHAR(50) NOT NULL
    )"
;

    
// use exec() because no results are returned
    
$dbconn->exec($sql);
    echo 
"Table created successfully";
}
catch(
PDOException $e)
    {
    echo 
$sql "<br>" $e->getMessage();
}
try {

    
// sql to create table
    
$sql "CREATE TABLE players (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
    name VARCHAR(30) NOT NULL,
    age INT(2) NOT NULL,
    rating INT(2) NOT NULL,
    nation VARCHAR(30) NOT NULL,
    position VARCHAR(4) NOT NULL,
    pace INT(2) NOT NULL,
    shooting INT(2) NOT NULL,
    passing INT(2) NOT NULL,
    dribbling INT(2) NOT NULL,
    defending INT(2) NOT NULL,
    physical INT(2) NOT NULL
    )"
;

    
// use exec() because no results are returned
    
$dbconn->exec($sql);
    echo 
"Table created successfully";
}
catch(
PDOException $e)
    {
    echo 
$sql "<br>" $e->getMessage();
}
try {

    
// sql to create table
    
$sql "CREATE TABLE owned_cards (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
    user_id INT(6) UNSIGNED, 
    player_id INT(6) UNSIGNED,
    FOREIGN KEY (user_id) REFERENCES projektusers(id),
    FOREIGN KEY (player_id) REFERENCES players(id) 
    )"
;

    
// use exec() because no results are returned
    
$dbconn->exec($sql);
    echo 
"Table created successfully";
}
catch(
PDOException $e)
    {
    echo 
$sql "<br>" $e->getMessage();
}
try {

    
// sql to create table
    
$sql "CREATE TABLE startelva (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
    userid INT(6) UNSIGNED,
    owned_id INT(6) UNSIGNED,
    position INT(2) UNSIGNED NOT NULL,
    FOREIGN KEY (userid) REFERENCES projektusers(id),
    FOREIGN KEY (owned_id) REFERENCES owned_cards(id)
    )"
;

    
// use exec() because no results are returned
    
$dbconn->exec($sql);
    echo 
"Table created successfully";
}
catch(
PDOException $e)
    {
    echo 
$sql "<br>" $e->getMessage();
}
$dbconn null;

?>
</body>

</html>