if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
die("Invalid ID specified.");
}
$id = (int)$_GET['id'];
$sql = "SELECT * FROM php_blog WHERE id='$id' LIMIT 1";
$result = mysql_query($sql) or print ("Can't select entry from table php_blog.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$date = date("l F d Y", $row['timestamp']);
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
$password = $row['password'];
$get_categories = mysql_query("SELECT * FROM php_blog_categories WHERE `category_id` = $row[category]");
$category = mysql_fetch_array($get_categories);
if ($password == 1) {
if (isset($_POST['username']) && $_POST['username'] == $my_username) {
if (isset($_POST['pass']) && $_POST['pass'] == $my_password) {
?>
<p><strong><?php echo $title; ?></strong><br /><br />
<?php echo $entry; ?><br /><br />
Posted in <?php echo $category['category_name']; ?> on <?php echo $date; ?></p>
<?php
}
else { ?>
<p>Sorry, wrong password.</p>
<?php
}
}
else {
echo "<p><strong>" . $title . "</strong></p>";
printf("<p>This is a password protected entry. If you have a password, log in below.</p>");
printf("<form method=\"post\" action=\"blog_single.php?id=%s\"><p><strong><label for=\"username\">Username:</label></strong><br /><input type=\"text\" name=\"username\" id=\"username\" /></p><p><strong><label for=\"pass\">Password:</label></strong><br /><input type=\"password\" name=\"pass\" id=\"pass\" /></p><p><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /></p></form>",$id);
print "<br /><br />";
}
}
else { ?>
Bookmarks