I set up a enable/disable button in an admin panel
http://brettadamsga.com/development/madisonweddings/admin/clients.php
The buttons work sometimes, and then at other times don’t, I have no idea what could cause this. Any ideas?
Creates the list of clients
<?php
dbcon();
$navQuery = 'SELECT * FROM mw_clients WHERE status = 1';
$li = mysql_query($navQuery);
while($row = mysql_fetch_array($li){
echo "<tr><td><a href=\"index.php?loc=" . $row['clientSlug'] . "\">" . $row['name'] . "</a></td><td align=\"center\"><a style=\"text-decoration: none;\" href=\"changeStatus.php?type=2&id=" . $row['id'] . "&status=0\">✕</a></td></tr>";
}
?>
changeStatus.php
<?php
require ('../common.php');
$type=$_GET["type"];
$id=$_GET["id"];
$status=$_GET["status"];
if ($status == 0 && $type == 1)
{
dbcon();
$query = "UPDATE mw_cats SET status=0 WHERE id=" . $id . "";
if (mysql_query($query))
{
echo mysql_error();
mysql_close();
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: categories.php');
} else {
echo '<p>Could not change status</p>';
}
}
if ($status == 1 && $type == 1)
{
dbcon();
$query = "UPDATE mw_cats SET status=1 WHERE id=" . $id . "";
if (mysql_query($query))
{
echo mysql_error();
mysql_close();
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: categories.php');
} else {
echo '<p>Could not change status</p>';
}
}
if ($status == 0 && $type == 2)
{
dbcon();
$query = "UPDATE mw_clients SET status=0 WHERE id=" . $id . "";
if (mysql_query($query))
{
echo mysql_error();
mysql_close();
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: clients.php');
} else {
echo '<p>Could not change status</p>';
}
}
if ($status == 1 && $type == 2)
{
dbcon();
$query = "UPDATE mw_clients SET status=1 WHERE id=" . $id . "";
if (mysql_query($query))
{
echo mysql_error();
mysql_close();
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: clients.php');
} else {
echo '<p>Could not change status</p>';
}
}
?>
It is being caused by your permanent redirects. They get cached by the browser so the next time you access it goes direct to the redirected page instead of running the script.