website/news_add.php
2007-03-22 05:41:10 +00:00

44 lines
No EOL
1.3 KiB
PHP

<? // Preamble
$pageName = "Add News";
$need = 'auth';
require "parts/preamble.php"; // Load most of document
need ('boxes html news sql');
$newsText = addSlashes($_REQUEST['newsText']);
$mode = $_REQUEST['mode'];
$user = $userInfo['u_displayname'];
if ($newsText && $mode == "Post") {
$query = 'INSERT into news_main (n_date, n_user, n_news) VALUES ('
."NOW(), '$user', '$newsText')";
$rows = sqlWriteQuery ($query);
if ($rows === null) {
echo '<P>You suck, butthead.</P>';
} elseif ($rows === false) {
echo '<P>There was an error in your input. If you don\'t know what it is, I\'m not going to tell you.</P>';
} else {
echo '<P>Your news item has been processed successfully.</P>';
}
} else {
$date = date ('d M Y');
newsBoxOpen ();
if ($newsText) {
newsBoxTitle ("Latest News (Preview)");
printNews ($date, $user, stripSlashes ($newsText));
}
newsBoxTitle ("Post News");
$form = '<FORM action="' . thisURL . '" method="post">'
. '<TEXTAREA name="newsText" rows="25" cols="64">'
. convertFromHTML (stripSlashes ($newsText))
. '</TEXTAREA><BR>'
. '<INPUT align="center" type="submit" name="mode" value="Post"></INPUT>'
. '<INPUT align="center" type="submit" name="mode" value="Preview"></INPUT>'
.'</FORM>';
printNews ($date, $user, $form);
newsBoxClose ();
}
?>