Webbserverprogrammering 1

Källkod

Följande filer och mappar finns under mappen webbserverprogrammering.
Mappar visas till vänster och filer till höger. Klicka på en fil eller mapp för att öppna nedan eller visa dess innehåll.

webbserverprogrammering/exercises/mysql/exercise_2/

11 filer

admin.php
back_button.php
create_table.php
dbconnection.php
delete_row.php
index.php
insert_default_values.php
insert_values.php
print_table.php
start.php
update_values.php

create_table.php

39 lines ASCII Windows (CRLF)
<!DOCTYPE html>
<html lang="sv">
<head>
 <title>Skapa tabell</title>
 <meta charset="utf-8">
</head>
<body>
 <?php
 
include('back_button.php');
 include (
'dbconnection.php');
 
 try {

  
// sql to create table
  
$sql "CREATE TABLE users (
  id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
  firstname VARCHAR(100) NOT NULL,
  lastname VARCHAR(100) NOT NULL,
  username VARCHAR(100) NOT NULL,
  password VARCHAR(100) NOT NULL,
  role VARCHAR(7) NOT NULL,
  last_edit DATETIME
  )"
;

  
// use exec() because no results are returned
  
$dbconn->exec($sql);
  echo 
"Tabellen 'users' skapades.";
 }
 catch(
PDOException $e)
 {
  echo 
$sql "<br>" $e->getMessage();
 }

 
// Close connection to database
 
$dbconn null;
 
 
?>
</body>
</html>