Webbserverprogrammering 1

Show sourcecode

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

webbserver/filmquiz/

api/
createroom.php
createtables.php
createuser.php
css/
dbconnection.php
game.php
index.php
login.php
logout.php
remove.php
rensa.php
results.php
waiting.php

dbconnection.php

25 lines UTF-8 Windows (CRLF)
<?php
session_start
();
$local false;
if(
$local){
  
$dbname 'filmquiz'
  
$hostname 'localhost';
  $
/* DB_USER, is removed and hidden for security reasons */ ;
  $
/* DB_PASSWORD, is removed and hidden for security reasons */ ;
}
else {
  
$dbname 'follun23';
  
$hostname 'localhost';
  $
/* DB_USER, is removed and hidden for security reasons */ ;
  $
/* DB_PASSWORD, is removed and hidden for security reasons */ ;
}
$options  = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'");

try {
    
$dbconn = new PDO("mysql:host=$hostname;dbname=$dbname;", $/* DB_USER, is removed and hidden for security reasons */ ;
    
$dbconn->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
}
catch(
PDOException $e){
    
// Skriv ut varför vi inte kan connecta
    
echo 'Connection failed: '.$e->getMessage()."<br />";
}