Hey everyone.
I am coding a staff panel at the moment and I'm having a little issue with the PHP sessions I'm guessing.
In one section it allows staff to post news which works 100% fine and displays 100% fine on my website.
It's only just came to my attention that when a staff member deletes the article, for some reason it logs them out after it's deleted. It's not a huge issue but I don't want my staff having to always log back after deleting a single article.
The page code is as follows:
(Cut out the code not related)
The log out issue only occurs when I delete items from the database. Insert, Select and Update work fine.
Any ideas? Let me know if you need more code.
I am coding a staff panel at the moment and I'm having a little issue with the PHP sessions I'm guessing.
In one section it allows staff to post news which works 100% fine and displays 100% fine on my website.
It's only just came to my attention that when a staff member deletes the article, for some reason it logs them out after it's deleted. It's not a huge issue but I don't want my staff having to always log back after deleting a single article.
The page code is as follows:
PHP Code:
<?php
session_start(); //allows session
include "config.php";
?>
<head>
<title>Snewsbox.NET Administration Panel</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
if($logged['id']){
switch($_GET['p']){
default:
?>
<div id="content"><div class="header">View Articles</div>
<table cellpadding="10" cellspacing="5" border="0">
<tr>
<th width="150" style="background-color:#EEE;padding:10px;">ID</th>
<th width="150" style="background-color:#EEE;padding:10px;">Article Title</th>
<th width="150" style="background-color:#EEE;padding:10px;">Author</th>
<th width="150" style="background-color:#EEE;padding:10px;">Actions</th>
</tr>
<?php
$gathernews = mysql_query("SELECT * FROM `news` ORDER BY `id` DESC");
while($listnews = mysql_fetch_array($gathernews)){
?>
<tr>
<td valign="top" style="background-color:#EEE;padding:10px;"><?php echo $listnews[id]; ?></td>
<td valign="top" style="background-color:#EEE;padding:10px;"><?php echo $listnews[title]; ?></td>
<td valign="top" style="background-color:#EEE;padding:10px;"><?php echo $listnews[author]; ?></td>
<td valign="top" style="background-color:#EEE;padding:10px;">
<a href="?p=delete&id=<?php echo $listnews[id]; ?>">Delete</a>
</td>
</tr>
<?php
}
echo "</table></div>";
break;
case "delete":
$id = $_GET['id'];
$sql = mysql_query("DELETE FROM `news` WHERE `id` = '$id'");
echo "Article Deleted";
break;
}
}
?>
</body>
The log out issue only occurs when I delete items from the database. Insert, Select and Update work fine.
Any ideas? Let me know if you need more code.
Comment