-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
34 lines (32 loc) · 1.38 KB
/
install.php
File metadata and controls
34 lines (32 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once 'lib/includes/config.php'; // Configuration file for turning error reporting and connection strings to database:
/*
* I think the following is pretty self explanatory and the index.php file helps you on how to insert and read
* data into a database table better.
*/
try {
$conn = new PDO('mysql:host=' . DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "CREATE DATABASE IF NOT EXISTS myCMS";
$conn->exec($sql);
$sql = "use myCMS";
$conn->exec($sql);
$sql = "CREATE TABLE IF NOT EXISTS myBlog (
ID int(11) AUTO_INCREMENT PRIMARY KEY,
title varchar(30) NOT NULL,
comment text NOT NULL,
date_added datetime NOT NULL DEFAULT '0000-00-00 00:00:00')";
$conn->exec($sql);
$sql = "CREATE TABLE IF NOT EXISTS myUsers ("
. "ID int(11) AUTO_INCREMENT PRIMARY KEY,"
. "name varchar(60) NOT NULL,"
. "password varchar(255) NOT NULL,"
. "email varchar(60) NOT NULL,"
. "security varchar(25) NOT NULL,"
. "confirmation varchar(255) NOT NULL,"
. "date_added datetime NOT NULL DEFAULT '0000-00-00 00:00:00')";
$conn->exec($sql);
echo "DB created successfully";
} catch (PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}