Cleaned up ugly HTML and renamed index.php to simplog.php
This commit is contained in:
parent
40de6d2290
commit
e886d4f461
8
includes/dbclose.php
Normal file
8
includes/dbclose.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
// Close MySQL link
|
||||
mysql_free_result($result);
|
||||
mysql_close($link);
|
||||
|
||||
|
||||
?>
|
18
includes/htmlcode.php
Normal file
18
includes/htmlcode.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
function start_html($title)
|
||||
{
|
||||
print "
|
||||
<html>
|
||||
<head>
|
||||
<title>$title</title>
|
||||
</head>
|
||||
<body>\n";
|
||||
}
|
||||
|
||||
function end_html()
|
||||
{
|
||||
print "\n\n</body>\n</html>\n";
|
||||
}
|
||||
|
||||
?>
|
@ -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 "<h2>" . $line['title'] . "</h2>";
|
||||
print "\n<p>";
|
||||
print $line['posttext'];
|
||||
print "\n<br/>" . $line['date'];
|
||||
print "</p>";
|
||||
print "<h2>$line[title]</h2>\n<p>";
|
||||
print "$line[posttext]\n<br />";
|
||||
print "Posted on: $line[date]";
|
||||
print "</p>\n\n";
|
||||
}
|
||||
|
||||
// Printing page links
|
||||
@ -43,10 +41,8 @@ for ($i=1; $i<=$total_posts; $i++)
|
||||
print "<a href='index.php?page=".$i."'>".$i."</a> ";
|
||||
}
|
||||
|
||||
|
||||
// Close MySQL link
|
||||
mysql_free_result($result);
|
||||
mysql_close($link);
|
||||
require "includes/dbclose.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();
|
||||
|
||||
?>
|
||||
|
@ -1,6 +1,9 @@
|
||||
<html><title>Edit post</title>
|
||||
<body>
|
||||
<?php
|
||||
require "../includes/htmlcode.php";
|
||||
start_html("Find post to edit");
|
||||
?>
|
||||
|
||||
<h1>Find post to edit</h1>
|
||||
<form action="editpost.php" method="get">
|
||||
Date: (YYYY-MM-DD) <input type="date" name="date">
|
||||
<br /><br />
|
||||
@ -9,6 +12,6 @@ Title: <input type="text" name="title">
|
||||
<input type="submit" value="Find post">
|
||||
</form>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
end_html();
|
||||
?>
|
@ -3,7 +3,10 @@
|
||||
// Include config file
|
||||
require "../includes/config.php";
|
||||
require "../includes/dbconnect.php";
|
||||
require "../includes/htmlcode.php";
|
||||
|
||||
start_html("Edit post");
|
||||
print "<h1>Edit post</h1>";
|
||||
|
||||
$query = "SELECT * FROM blog WHERE date='$_GET[date]' AND title='$_GET[title]'";
|
||||
$result = mysql_query($query)
|
||||
@ -24,13 +27,15 @@ Text: <br />
|
||||
<textarea cols='50' rows='10' name='post'>$line[posttext]</textarea>
|
||||
<br />
|
||||
<input type='submit' value='Update post'>
|
||||
</form>";
|
||||
</form>
|
||||
<hr width='50%' align='left'>
|
||||
<br />";
|
||||
}
|
||||
|
||||
|
||||
// Close MySQL link
|
||||
mysql_free_result($result);
|
||||
mysql_close($link);
|
||||
require "../includes/dbclose.php";
|
||||
|
||||
end_html();
|
||||
|
||||
?>
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
<html><title>simplog user interface</title>
|
||||
<body>
|
||||
|
||||
<h1>simplog user interface</h1>
|
||||
<p>
|
||||
<a href="newpost.html">Create new post</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="editpost.html">Edit existing post</a>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
16
user/index.php
Normal file
16
user/index.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
require "../includes/htmlcode.php";
|
||||
start_html("simlog user interface");
|
||||
?>
|
||||
|
||||
<h1>simplog user interface</h1>
|
||||
<p>
|
||||
<a href="new.php">Create new post</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="edit.php">Edit existing post</a>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
end_html();
|
||||
?>
|
@ -1,6 +1,9 @@
|
||||
<html><title>Create a new post</title>
|
||||
<body>
|
||||
<?php
|
||||
require "../includes/htmlcode.php";
|
||||
start_html("Create new post");
|
||||
?>
|
||||
|
||||
<h1>Create new post</h1>
|
||||
<form action="createpost.php" method="post">
|
||||
Date: (YYYY-MM-DD) <input type="date" name="date">
|
||||
<br />
|
||||
@ -12,5 +15,6 @@ Text: <br />
|
||||
<input type="submit" value="Create post">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
end_html();
|
||||
?>
|
@ -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();
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user