From e886d4f4619ba8c44057fae2b430db1663daaa25 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Sat, 27 Jul 2013 23:38:17 +0200 Subject: [PATCH] Cleaned up ugly HTML and renamed index.php to simplog.php --- includes/dbclose.php | 8 ++++++++ includes/htmlcode.php | 18 ++++++++++++++++++ index.php => simplog.php | 18 +++++++----------- user/createpost.php | 4 ++++ user/{editpost.html => edit.php} | 13 ++++++++----- user/editpost.php | 13 +++++++++---- user/index.html | 13 ------------- user/index.php | 16 ++++++++++++++++ user/{newpost.html => new.php} | 12 ++++++++---- user/updatepost.php | 4 ++++ 10 files changed, 82 insertions(+), 37 deletions(-) create mode 100644 includes/dbclose.php create mode 100644 includes/htmlcode.php rename index.php => simplog.php (74%) rename user/{editpost.html => edit.php} (61%) delete mode 100644 user/index.html create mode 100644 user/index.php rename user/{newpost.html => new.php} (69%) diff --git a/includes/dbclose.php b/includes/dbclose.php new file mode 100644 index 0000000..033b109 --- /dev/null +++ b/includes/dbclose.php @@ -0,0 +1,8 @@ + diff --git a/includes/htmlcode.php b/includes/htmlcode.php new file mode 100644 index 0000000..f084c18 --- /dev/null +++ b/includes/htmlcode.php @@ -0,0 +1,18 @@ + + +$title + +\n"; +} + +function end_html() +{ + print "\n\n\n\n"; +} + +?> diff --git a/index.php b/simplog.php similarity index 74% rename from index.php rename to simplog.php index 4d57df9..1f06de1 100644 --- a/index.php +++ b/simplog.php @@ -4,11 +4,10 @@ require "includes/config.php"; require "includes/dbconnect.php"; - // Divide the posts into pages, N number of posts on every page -if (isset($_GET["page"])) +if (isset($_GET['page'])) { - $page = $_GET["page"]; + $page = $_GET['page']; } else { @@ -24,11 +23,10 @@ $result = mysql_query($query) // Printing posts in HTML while ($line = mysql_fetch_array($result)) { -print "

" . $line['title'] . "

"; -print "\n

"; -print $line['posttext']; -print "\n
" . $line['date']; -print "

"; +print "

$line[title]

\n

"; +print "$line[posttext]\n
"; +print "Posted on: $line[date]"; +print "

\n\n"; } // Printing page links @@ -43,10 +41,8 @@ for ($i=1; $i<=$total_posts; $i++) print "".$i." "; } - // Close MySQL link -mysql_free_result($result); -mysql_close($link); +require "includes/dbclose.php"; ?> diff --git a/user/createpost.php b/user/createpost.php index b7617e4..4374822 100644 --- a/user/createpost.php +++ b/user/createpost.php @@ -3,6 +3,9 @@ // Include config file require "../includes/config.php"; require "../includes/dbconnect.php"; +require "../includes/htmlcode.php"; + +start_html("New post created"); $query = "INSERT INTO blog (date, title, posttext) VALUES @@ -18,5 +21,6 @@ print "Post added"; // Close MySQL link mysql_close($link); +end_html(); ?> diff --git a/user/editpost.html b/user/edit.php similarity index 61% rename from user/editpost.html rename to user/edit.php index 8f6d473..5a068e9 100644 --- a/user/editpost.html +++ b/user/edit.php @@ -1,6 +1,9 @@ -Edit post - + +

Find post to edit

Date: (YYYY-MM-DD)

@@ -9,6 +12,6 @@ Title:
- - - + diff --git a/user/editpost.php b/user/editpost.php index 036dcfc..9d33e70 100644 --- a/user/editpost.php +++ b/user/editpost.php @@ -3,7 +3,10 @@ // Include config file require "../includes/config.php"; require "../includes/dbconnect.php"; +require "../includes/htmlcode.php"; +start_html("Edit post"); +print "

Edit post

"; $query = "SELECT * FROM blog WHERE date='$_GET[date]' AND title='$_GET[title]'"; $result = mysql_query($query) @@ -24,13 +27,15 @@ Text:

-"; + +
+
"; } - // Close MySQL link -mysql_free_result($result); -mysql_close($link); +require "../includes/dbclose.php"; +end_html(); ?> + diff --git a/user/index.html b/user/index.html deleted file mode 100644 index 27476e4..0000000 --- a/user/index.html +++ /dev/null @@ -1,13 +0,0 @@ -simplog user interface - - -

simplog user interface

-

-Create new post -

-

-Edit existing post -

- - - diff --git a/user/index.php b/user/index.php new file mode 100644 index 0000000..30b3fa7 --- /dev/null +++ b/user/index.php @@ -0,0 +1,16 @@ + + +

simplog user interface

+

+Create new post +

+

+Edit existing post +

+ + diff --git a/user/newpost.html b/user/new.php similarity index 69% rename from user/newpost.html rename to user/new.php index 7f4b57f..ad65beb 100644 --- a/user/newpost.html +++ b/user/new.php @@ -1,6 +1,9 @@ -Create a new post - + +

Create new post

Date: (YYYY-MM-DD)
@@ -12,5 +15,6 @@ Text:
- - + diff --git a/user/updatepost.php b/user/updatepost.php index ed25efe..6c79e1e 100644 --- a/user/updatepost.php +++ b/user/updatepost.php @@ -3,6 +3,9 @@ // Include config file require "../includes/config.php"; require "../includes/dbconnect.php"; +require "../includes/htmlcode.php"; + +start_html("Post updated"); $query = "UPDATE blog SET date='$_POST[date]', title='$_POST[title]', @@ -18,5 +21,6 @@ print "Post updated"; // Close MySQL link mysql_close($link); +end_html(); ?>