.
*/
/**
* Note to anyone feeling the need to edit this file...
* You MUST declare $db as global inside your functions in order access MySQL from here.
*/
function EditAnnouncements()
{
global $db;
if(isset($_POST['processed']))
{
//Secure our data to prevent injection attacks.
$title = addslashes($_POST['title']);
$text = addslashes($_POST['text']);
if(empty($title) || empty($text))
{
echo "You must fill everything out before proceeding.";
return;
}
//Update the database with the new data.
$db->Query("UPDATE bayonet_announcements SET title = '$title', text = '$text' WHERE announcement_id = 0");
echo "Announcement, '$title', has been edited.\n
Please wait while you are redirected.
Click here if you don't feel like waiting.";
// 3 second redirect to go back to the edit page
PageRedirect(2, "?op=announcements");
//die, because we have completed what we wanted to do.
return;
}
//Grab the page from the database according to the $article_id passed to the function.
$result = $db->Query("SELECT title,text FROM bayonet_announcements WHERE announcement_id = 0");
$announcement = $db->FetchRow($result);
?>