Location: PHPKode > projects > bloggeruniverse > update.php
<?php
ob_start();
session_start();
include ("includes/config.php");
require ("theme.php");
$page->settitle("Update Entry");
$page->output();
if (($logged[username]) && ($logged[level] == 5))
{
$result = mysql_query ("SELECT * FROM ".PREFIX."blog WHERE id=$id") or print (mysql_error());
while ($row = mysql_fetch_array($result))
	{
		$old_timestamp = $row["timestamp"];
		$old_title = $row["title"];
		$old_entry = $row["entry"];
		$old_password = $row["password"];

		$old_title = str_replace('"','\'',$old_title);

		$old_month = date("F",$old_timestamp);
		$old_date = date("d",$old_timestamp);
		$old_year = date("Y",$old_timestamp);
		$old_time = date("H:i",$old_timestamp);
	}


echo "<form method=\"post\" action=\"$PHP_SELF\">
<input type=\"hidden\" name=\"id\" value=\"$id\">
	<table>
		<tr>
			<td>
				<b>date:</b>

				<select name=\"month\">
				<option value=\"$old_month\">$old_month</option>
				<option value=\"January\">January</option>
				<option value=\"February\">February</option>
				<option value=\"March\">March</option>
				<option value=\"April\">April</option>
				<option value=\"May\">May</option>
				<option value=\"June\">June</option>
				<option value=\"July\">July</option>
				<option value=\"August\">August</option>
				<option value=\"September\">September</option>
				<option value=\"October\">October</option>
				<option value=\"November\">November</option>
				<option value=\"December\">December</option>
				</select>

				<input type=\"text\" name=\"date\" size=\"2\" value=\"$old_date\">

				<select name=\"year\">
				<option value=\"$old_year\">$old_year</option>
				<option value=\"2004\">2004</option>
				<option value=\"2005\">2005</option>
				<option value=\"2006\">2006</option>
				<option value=\"2007\">2007</option>
				<option value=\"2008\">2008</option>
				<option value=\"2009\">2008</option>
				<option value=\"2010\">2010</option>
				</select>

				<input type=\"text\" name=\"time\" size=\"5\" value=\"$old_time\">
			</td>
		</tr>
		<tr>
			<td>
				<b>title:</b> <input type=\"text\" name=\"title\" size=\"40\" value=\"$old_title\">
			</td>
		</tr>
		<tr>
			<td>
				<textarea cols=\"80\" rows=\"20\" name=\"entry\">$old_entry</textarea>
			</td>
		</tr>
		<tr>
			<td>
				<input type=\"submit\" name=\"update\" value=\"Update\">
			</td>
		</tr>
	</table>
</form>";
echo "<table>
	<tr>
		<td>
		<p><b>Before deleting, be absolutely sure - there is no confirmation nor is there any way to reverse deletion!!</b><br />
		<font size='1'>(You may be shown your entry again after deleting, do not worry, it HAS been deleted.  Check the main page of the blog if you are still unsure.</font></p>
		<form action='$PHP_SELF' method='post'>
		<input type='hidden' name='id' value='$id'>
		<input type='submit' name='delete' value='Yes, I am absolutely and positively sure I want to delete this entry.'>
		</form>
</td>
</tr>
</table>";

	if($_POST[update])
    {
    $timestamp = strtotime ("$month $date $year $time");
	$result = mysql_query("UPDATE ".PREFIX."blog SET timestamp='$timestamp', title='$title', entry='$entry' WHERE id = '$id'") or print (mysql_error());
	echo "<meta HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=index.php?id=$id\">";
	}
     
	if($_POST[delete])
	{
	$id = $_POST[id];
	$result = mysql_query("DELETE FROM ".PREFIX."blog WHERE id = '$id'") or print (mysql_error());

		if ($result != false)
		{
			echo "<b>Your entry has successfully been deleted from the database!</b>";
		}
	}
}
else
{
echo NOT_ADMIN;
}
$content->output();
$close->output();
?>
Return current item: bloggeruniverse