Jump to content

Recommended Posts

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">';
}

}
?>

Link to comment
https://forums.phpfreaks.com/topic/97192-logs-me-out/
Share on other sites

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">';
}

}
?>

Link to comment
https://forums.phpfreaks.com/topic/97192-logs-me-out/#findComment-497328
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/97192-logs-me-out/#findComment-497338
Share on other sites

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";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/97192-logs-me-out/#findComment-497348
Share on other sites

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";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/97192-logs-me-out/#findComment-497352
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.