<?php
include("./dbconnect.php");//include the file that connects to the database
if(!empty($title)) {//if the title is not empty, than do this function
$title = addslashes($title);
$user = addslashes($user);
$message = addslashes($message);
$date = date("F j, Y");//set up the date format
$date2 = mktime();
$sql = "INSERT INTO mynews (id, title, user, message, date) VALUES ('NULL', '$title','$user','$message','$date')";//Insert all of your information into the mynews table in your database
$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
echo "Database Updated.";
} else {//However, if the title variable is empty, than do this function
?>
<form name="news" method="post" action="<?php echo $PHP_SELF; ?>">
<p>Please fill out all of the following fields:</p>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="117"><font size="1">News Topic/Title*: </font> </td>
<td width="577">
<font size="1">
<input type="text" name="title" size="50">
</font>
</td>
</tr>
<tr>
<td width="117"><font size="1">Username*:</font></td>
<td width="577">
<font size="1">
<input type="text" name="user" size="50">
</font>
</td>
</tr>
<tr>
<td width="117"><font size="1">Message*:</font></td>
<td width="577">
<font size="1">
<textarea name="message" rows=10 cols=43></textarea>
</font>
</td>
</tr>
</table>
<p>
<font size="1">
<input type="submit" name="Submit" value="Submit"></font>
</p>
</form> <?php
}//end this function
?>
and this is the code so only registered users can see a page;
<?PHP
include("include/session.php");
if($session->logged_in){
echo "what you see as registered";
}
else{
echo "what you see as guest.";
}
?>
So I would like to have it so you have to be registered to be able to see the submit.php page, anyone know how i would do this? also I would like it so only admins can see it, anyone know how to do that? the admins level is 9 (both news and user groups is using the same database) and user 1, guest 0.
Hope someone can help, thanks. :XD:
