hello,
i was wondering why the information from the form i created wont go into my mysql DB. here is the code:
//======================================================\\
//News Form
//======================================================\\
function newsForm() {
?>
<div class="adminMenu2">
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input type="hidden" name="cmd" value="postNewsItem">
<table width="300" align="left" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="td1">
Title:
<br>
<input type="textfield" name="newsSubject" class="textBox"></td>
</tr>
<tr>
<td class="td1">
Link:
<br>
<input type="textfield" name="newsLink" class="textBox"></td>
</tr>
<tr>
<td width="100" class="td1">
<input type="radio" name="newsCat" value="art">Art
<br>
<input type="radio" name="newsCat" value="fashion">Fashion
<br>
<input type="radio" name="newsCat" value="internalUpdates">Internal Updates
<br>
<input type="radio" name="newsCat" value="music">Music
<br>
<input type="radio" name="newsCat" value="other">Other
<br>
<input type="radio" name="newsCat" value="politics">Politics
<br>
</td>
</tr>
<tr>
<td class="td1">
News:
<br>
<textarea name="newsPost" rows="25" class="textBox"></textarea>
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit" value="POST NEWS">
<input type="reset" name="clear" value="CLEAN ENTRY">
</td>
</tr>
</table>
</form>
</div>
<?
}
//======================================================\\
// POST THE NEWS ITEM INTO THE DATABASE
// THIS SECTION WILL ALSO CHECK TO SEE IF ALL FIELDS HAVE
// FILLED OUT AND IF SO THEN THE INFORMATION WILL BE
// ENTERED INTO THE DATABASE.
//======================================================\\
function postNewsItem() {
global $newsTable;
if(empty($_POST['newsSubject'])) error_message("PLEASE ENTER A TITLE");
if(empty($_POST['newsLink'])) error_message("PLEASE ENTER A LINK FOR THE NEWS POST");
if(empty($_POST['newsPost'])) error_message("YOU HAVE NOT ENTERED ANYTHING IN THE NEWS BOX");
$linkID = db_connect('guernica');
$result = mysql_query("INSERT INTO $newsTable VALUES(NULL, '$_POST[newsSubject]', '$_POST[newsLink]', '$_POST[newsCat]', '$_POST[newsPost]', CURDATE())", $linkID);
echo "YOUR NEWS ITEM HAS BEEN POSTED, THANK YOU";
}
they form and functions run via a switch command:
switch($_REQUEST['cmd']) {
default:
htmlHeader();
navigation();
htmlFooter();
break;
case "newsForm":
htmlHeader();
navigation();
newsForm();
htmlFooter();
break;
case "postNewsItem":
htmlHeader();
navigation();
postNewsItem();
htmlFooter();
break;
case "logout":
htmlHeader();
logout();
htmlFooter();
break;
}
it seems to all be correct but for some reason the postNewsItem() function is not working.
any help would greatly be appreciated!