From be4f83cd2a17a0ec05f5bce50c91befaafaa6e0c Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sun, 20 Dec 2009 18:38:08 +0000 Subject: Test. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@376 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- admin/announcements/functions.php | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 admin/announcements/functions.php (limited to 'admin/announcements/functions.php') diff --git a/admin/announcements/functions.php b/admin/announcements/functions.php new file mode 100644 index 0000000..2e55125 --- /dev/null +++ b/admin/announcements/functions.php @@ -0,0 +1,70 @@ +. + */ + +/** + * 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['announcementprocessed'])) + { + //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 + echo ""; + + //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"); + while(($row = $db->Fetch($result))!=false) + { + //We only want one row, so we don't have to $article[]... No foreach necessary. + $announcement = $row; + } + ?> +
+ + + + +
Announcement Title:
+
+ \ No newline at end of file -- cgit