26 lines
844 B
PHP
26 lines
844 B
PHP
|
<?php
|
||
|
session_start();
|
||
|
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
||
|
require($root."/database/credentials.php");
|
||
|
|
||
|
ini_set('display_errors', 1);
|
||
|
ini_set('display_startup_errors', 1);
|
||
|
error_reporting(E_ALL);
|
||
|
|
||
|
// Connect the database
|
||
|
try{
|
||
|
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8",
|
||
|
$user,
|
||
|
$password,
|
||
|
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||
|
));
|
||
|
}catch (Exception $e){
|
||
|
die("Error : ".$e->getMessage());
|
||
|
}
|
||
|
|
||
|
/* Create Table if not exists */
|
||
|
$req = $db->prepare('CREATE TABLE IF NOT EXISTS golden_book ( `id` INT NOT NULL AUTO_INCREMENT , `firstname` VARCHAR(25) NOT NULL , `lastname` VARCHAR(25) NOT NULL , `email` VARCHAR(125) NOT NULL, `date` DATE NOT NULL DEFAULT CURRENT_TIMESTAMP , `message` TEXT NOT NULL , `website` VARCHAR(125) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;');
|
||
|
$req->execute();
|
||
|
|
||
|
?>
|