Skip to content
Snippets Groups Projects
Commit 80391536 authored by Tran Le's avatar Tran Le
Browse files

first commit: Step 1 files

parents
Branches
No related merge requests found
File added
<a href='admin.php?page=entries'>All entries</a>
<a href='admin.php?page=editor'>Editor</a>
<?php
error_reporting(E_ALL);
ini_set( "display_errors", 1 );
//Establish connection with database using PDO
include '../../../config.php';
$db = new PDO( $dbInfo, $dbUser, $dbPassword );
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$title = "PHP/MySQL Blog";
$css="css/blog.css";
$embeddedStyle = "";
include_once "views/header.php";
include_once "views/admin/navigation.php";
$navigation = isset( $_GET['page'] );
if ( $navigation ) {
//prepare to load corresponding controller
$contrl = $_GET['page'];
} else {
//or prepare to load default controller
$contrl = "controller";
}
//load the controller
include_once "controllers/admin/$contrl.php";
include_once "views/footer.php";
?>
\ No newline at end of file
<?php
?>
\ No newline at end of file
CREATE TABLE blog_entry (
id INT AUTO_INCREMENT,
title VARCHAR(140) NOT NULL,
text TEXT,
date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) ENGINE=InnoDB;
File added
File added
<?php
$content = "
<form method='post' action='admin.php?page=editor' id='editor'>
<fieldset>
<legend>New Entry Submission</legend>
<label>Title</label>
<input type='text' name='title' maxlength='150' />
<label>Entry</label>
<textarea name='entry'></textarea>
<fieldset id='editor-buttons'>
<input type='submit' name='action' value='save' />
</fieldset>
</fieldset>
</form>
";
echo $content;
?>
\ No newline at end of file
<?php
$entriesAsHTML = "<ul>";
while ( $entry = $allEntries->fetchObject() ) {
$href = "admin.php?page=editor&amp;id=$entry->entry_id";
$entriesAsHTML .= "<li><a href='$href'>$entry->title</a></li>";
}
$entriesAsHTML .= "</ul>";
echo $entriesAsHTML;
?>
\ No newline at end of file
<?php
$content = "<nav id='admin-navigation'>
<a href='admin.php?page=entries'>All entries</a>
<a href='admin.php?page=editor'>Editor</a>
</nav>";
echo $content;
?>
\ No newline at end of file
<?php
$content = "
</body>
</html>
";
echo $content;
?>
\ No newline at end of file
<?php
$content = "<!DOCTYPE html>
<html>
<head>
<title>$title</title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8' />
<link rel='stylesheet' type='text/css' href='$css'>
<link rel='stylesheet' type='text/css' href='$embeddedStyle'>
</head>";
echo $content;
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment