Lamez Posted March 21, 2008 Share Posted March 21, 2008 every time I delete a topic on my custom message board, it logs me off. Why? here is the code: <?php include ("../../style/include/session.php"); if($session->isAdmin()){ $tbl_name="forum_question"; $tbl_name2="forum_answer"; $lock = "lockt"; $unlock = "unlockt"; $stick = "stick"; $unstick = "unstick"; $dele = "dele"; $userid = "userid"; $id = $_POST['id']; if ($lock = ($_POST['lockt'])){ mysql_query("UPDATE $tbl_name SET locked = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unlock = ($_POST['unlockt'])){ mysql_query("UPDATE $tbl_name SET locked = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($stick = ($_POST['stick'])){ mysql_query("UPDATE $tbl_name SET sticky = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unstick = ($_POST['unstick'])){ mysql_query("UPDATE $tbl_name SET sticky = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($dele = ($_POST['dele'])){ mysql_query("DELETE FROM $tbl_name WHERE id = $id") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=main_forum.php">'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/97192-logs-me-out/ Share on other sites More sharing options...
Lamez Posted March 21, 2008 Author Share Posted March 21, 2008 I have add '$id' now, but same thing happens. <?php include ("../../style/include/session.php"); if($session->isAdmin()){ $tbl_name="forum_question"; $tbl_name2="forum_answer"; $lock = "lockt"; $unlock = "unlockt"; $stick = "stick"; $unstick = "unstick"; $dele = "dele"; $userid = "userid"; $id = $_POST['id']; if ($lock = ($_POST['lockt'])){ mysql_query("UPDATE $tbl_name SET locked = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unlock = ($_POST['unlockt'])){ mysql_query("UPDATE $tbl_name SET locked = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($stick = ($_POST['stick'])){ mysql_query("UPDATE $tbl_name SET sticky = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unstick = ($_POST['unstick'])){ mysql_query("UPDATE $tbl_name SET sticky = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($dele = ($_POST['dele'])){ mysql_query("DELETE FROM $tbl_name WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=main_forum.php">'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/97192-logs-me-out/#findComment-497328 Share on other sites More sharing options...
PFMaBiSmAd Posted March 21, 2008 Share Posted March 21, 2008 All of your if() conditional tests are using a single equal sign =. That is assigning a value, not testing if it is equal. You need two equal signs to test for equality == However, I suspect that your log out problem is because your isAdmin() class function is probably using a global/hard-coded variable that your code is overwriting instead of using proper private variables inside of the class. You would need to post your class code to get any help with what it is doing. Quote Link to comment https://forums.phpfreaks.com/topic/97192-logs-me-out/#findComment-497338 Share on other sites More sharing options...
Lamez Posted March 21, 2008 Author Share Posted March 21, 2008 function isAdmin(){ return ($this->userlevel == ADMIN_LEVEL || $this->username == ADMIN_NAME); } in session.php Quote Link to comment https://forums.phpfreaks.com/topic/97192-logs-me-out/#findComment-497344 Share on other sites More sharing options...
Lamez Posted March 21, 2008 Author Share Posted March 21, 2008 duh == well that fixed the logout problem, but now it does not go through the process, say I try to stick a topic, it will not do it, and it does not redirect. new code: <?php include ("../../style/include/session.php"); if($session->isAdmin()){ $tbl_name="forum_question"; $tbl_name2="forum_answer"; $lock = "lockt"; $unlock = "unlockt"; $stick = "stick"; $unstick = "unstick"; $dele = "dele"; $id = $_POST['id']; if ($lock == ($_POST['lockt'])){ mysql_query("UPDATE $tbl_name SET locked = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unlock == ($_POST['unlockt'])){ mysql_query("UPDATE $tbl_name SET locked = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($stick == ($_POST['stick'])){ mysql_query("UPDATE $tbl_name SET sticky = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unstick == ($_POST['unstick'])){ mysql_query("UPDATE $tbl_name SET sticky = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($dele == ($_POST['dele'])){ mysql_query("DELETE FROM $tbl_name WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=main_forum.php">'; } }else{ echo "NOT ADMIN"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/97192-logs-me-out/#findComment-497348 Share on other sites More sharing options...
Lamez Posted March 21, 2008 Author Share Posted March 21, 2008 TOPIC SOLVED, lol why not just use isset's? finished code: <?php include ("../../style/include/session.php"); if($session->isAdmin()){ $tbl_name="forum_question"; $tbl_name2="forum_answer"; $id = $_POST['id']; if (isset ($_POST['lockt'])){ mysql_query("UPDATE $tbl_name SET locked = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if (isset ($_POST['unlockt'])){ mysql_query("UPDATE $tbl_name SET locked = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if (isset ($_POST['stick'])){ mysql_query("UPDATE $tbl_name SET sticky = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if (isset ($_POST['unstick'])){ mysql_query("UPDATE $tbl_name SET sticky = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if (isset ($_POST['dele'])){ mysql_query("DELETE FROM $tbl_name WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=main_forum.php">'; } }else{ echo "NOT ADMIN"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/97192-logs-me-out/#findComment-497352 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.