Jump to content

its not working :((


seany123

Recommended Posts

okay i have a page which worked fine but then i added a line of code for security and now it doesnt display the values from my database when i click pending and fixed....

 

here is the code i added:

if($player['staff'] <= 2)
{
header("Location: home.php");
}
else
{

 

and this is the page with the code added:

 

<?php
include("lib.php");
define("PAGENAME", "Bug List");
$player = check_user($secret_key, $db);

include("templates/private_header.php");

if($player['staff'] <= 2)
{
header("Location: home.php");
}
else
{

if (isset($_GET['fixed'])) {

$query = $db->execute("select * from `bugs` where status='Fixed'");	

while ($buglist= $query->fetchrow()) {
$idstr = $buglist['id'] . "";
$usernamestr = $buglist['username'] . "";
    $messagestr = $buglist['comment'] . "";
    $statusstr = "<font color=green>" . $buglist['status'] . "</color>";

    echo "<table>";
    echo "<tr><td><b>Bug ID: </b>$idstr</td></tr>";
    echo "<tr><td><b>Username: </b>$usernamestr</td></tr>";
    echo "<tr><td><b>Bug Report: </b>$messagestr</td></tr>";
    echo "<tr><td><b>Status: </b>$statusstr</td></tr>";
    echo "</table><p />";
}
}

if (isset($_GET['pending'])) {

$query = $db->execute("select * from `bugs` where status='Pending'");

while ($buglist = $query->fetchrow()) {
$idstr = $buglist['id'] . "";
$usernamestr = $buglist['username'] . "";
    $messagestr = $buglist['comment'] . "";
    $statusstr = "<font color=red>" . $buglist['status'] . "</color>";
    

    echo "<table>";
    echo "<tr><td><b>Bug ID: </b>$idstr</td></tr>";
    echo "<tr><td><b>Username: </b>$usernamestr</td></tr>";
    echo "<tr><td><b>Bug Report: </b>$messagestr</td></tr>";
    echo "<tr><td><b>Status: </b>$statusstr</td></tr>";
    echo "</table><p />";
}
   }
}
?>

<center>
<form method="GET" action="bugslist.php">
<input type="submit" name="fixed" value="Fixed Bugs">
<input type="submit" name="pending" value="Pending Bugs">
<p /><b>Select which type of bugs you would like to check.</b><p />
</center>

<?php include("templates/private_footer.php")
?>

Link to comment
Share on other sites

Backup your code and change it to the following:

 

<?php
include("lib.php");
define("PAGENAME", "Bug List");
$player = check_user($secret_key, $db);
echo "<script language="JavaScript" type="text/javascript">alert(\"" . $player['staff'] . "\")</script>"
include("templates/private_header.php");

if($player['staff'] <= 2)
{
header("Location: home.php");
}
else
{

if (isset($_GET['fixed'])) {
   
   $query = $db->execute("select * from `bugs` where status='Fixed'");   
   
   while ($buglist= $query->fetchrow()) {
   $idstr = $buglist['id'] . "";
   $usernamestr = $buglist['username'] . "";
    $messagestr = $buglist['comment'] . "";
    $statusstr = "<font color=green>" . $buglist['status'] . "</color>";

    echo "<table>";
    echo "<tr><td><b>Bug ID: </b>$idstr</td></tr>";
    echo "<tr><td><b>Username: </b>$usernamestr</td></tr>";
    echo "<tr><td><b>Bug Report: </b>$messagestr</td></tr>";
    echo "<tr><td><b>Status: </b>$statusstr</td></tr>";
    echo "</table><p />";
   }
}

if (isset($_GET['pending'])) {
   
   $query = $db->execute("select * from `bugs` where status='Pending'");
   
   while ($buglist = $query->fetchrow()) {
   $idstr = $buglist['id'] . "";
   $usernamestr = $buglist['username'] . "";
    $messagestr = $buglist['comment'] . "";
    $statusstr = "<font color=red>" . $buglist['status'] . "</color>";
    

    echo "<table>";
    echo "<tr><td><b>Bug ID: </b>$idstr</td></tr>";
    echo "<tr><td><b>Username: </b>$usernamestr</td></tr>";
    echo "<tr><td><b>Bug Report: </b>$messagestr</td></tr>";
    echo "<tr><td><b>Status: </b>$statusstr</td></tr>";
    echo "</table><p />";
   }
   }
}
?>

<center>
<form method="GET" action="bugslist.php">
<input type="submit" name="fixed" value="Fixed Bugs">
<input type="submit" name="pending" value="Pending Bugs">
<p /><b>Select which type of bugs you would like to check.</b><p />
</center>

<?php include("templates/private_footer.php")
?>

Link to comment
Share on other sites

I've indented the code to make it a little more readable and added a line (which I've commented) - see what it displays.

 

<?php
include("lib.php");
define("PAGENAME", "Bug List");
$player = check_user($secret_key, $db);

include("templates/private_header.php");

echo 'player[staff]='.$player['staff']; //LET'S SEE WHAT WE'RE PLAYING WITH

if($player['staff'] <= 2) {
  header("Location: home.php");
} else {

  if (isset($_GET['fixed'])) {
     
    $query = $db->execute("select * from `bugs` where status='Fixed'");   
     
    while ($buglist= $query->fetchrow()) {
      $idstr = $buglist['id'] . "";
      $usernamestr = $buglist['username'] . "";
      $messagestr = $buglist['comment'] . "";
      $statusstr = "<font color=green>" . $buglist['status'] . "</color>";

      echo "<table>";
      echo "<tr><td><b>Bug ID: </b>$idstr</td></tr>";
      echo "<tr><td><b>Username: </b>$usernamestr</td></tr>";
      echo "<tr><td><b>Bug Report: </b>$messagestr</td></tr>";
      echo "<tr><td><b>Status: </b>$statusstr</td></tr>";
      echo "</table><p />";
    }
  }

  if (isset($_GET['pending'])) {
     
    $query = $db->execute("select * from `bugs` where status='Pending'");
     
    while ($buglist = $query->fetchrow()) {
      $idstr = $buglist['id'] . "";
      $usernamestr = $buglist['username'] . "";
      $messagestr = $buglist['comment'] . "";
      $statusstr = "<font color=red>" . $buglist['status'] . "</color>";
      

      echo "<table>";
      echo "<tr><td><b>Bug ID: </b>$idstr</td></tr>";
      echo "<tr><td><b>Username: </b>$usernamestr</td></tr>";
      echo "<tr><td><b>Bug Report: </b>$messagestr</td></tr>";
      echo "<tr><td><b>Status: </b>$statusstr</td></tr>";
      echo "</table><p />";
    }
  }
}
?>

<div align="center">
<form method="GET" action="bugslist.php">
<input type="submit" name="fixed" value="Fixed Bugs">
<input type="submit" name="pending" value="Pending Bugs">
<p /><b>Select which type of bugs you would like to check.</b><p />
</div>

<?php include("templates/private_footer.php"); ?>

Link to comment
Share on other sites

i also changed the if statement to same format... its worked in a way that now its allowing me to see the two fields....

 

but its not redirecting the people who have a staff value of 2 and under.

 

instead they can still view the page but they cant view the database fields.

 

heres what i got now....

 

<?php
include("lib.php");
define("PAGENAME", "Bug List");
$player = check_user($secret_key, $db);

include("templates/private_header.php");

echo 'player->staff ='.$player->staff; //LET'S SEE WHAT WE'RE PLAYING WITH

if($player->staff <= 2) {
  header("Location: home.php");
} else {

  if (isset($_GET['fixed'])) {
     
    $query = $db->execute("select * from `bugs` where status='Fixed'");   
     
    while ($buglist= $query->fetchrow()) {
      $idstr = $buglist['id'] . "";
      $usernamestr = $buglist['username'] . "";
      $messagestr = $buglist['comment'] . "";
      $statusstr = "<font color=green>" . $buglist['status'] . "</color>";

      echo "<table>";
      echo "<tr><td><b>Bug ID: </b>$idstr</td></tr>";
      echo "<tr><td><b>Username: </b>$usernamestr</td></tr>";
      echo "<tr><td><b>Bug Report: </b>$messagestr</td></tr>";
      echo "<tr><td><b>Status: </b>$statusstr</td></tr>";
      echo "</table><p />";
    }
  }

  if (isset($_GET['pending'])) {
     
    $query = $db->execute("select * from `bugs` where status='Pending'");
     
    while ($buglist = $query->fetchrow()) {
      $idstr = $buglist['id'] . "";
      $usernamestr = $buglist['username'] . "";
      $messagestr = $buglist['comment'] . "";
      $statusstr = "<font color=red>" . $buglist['status'] . "</color>";
      

      echo "<table>";
      echo "<tr><td><b>Bug ID: </b>$idstr</td></tr>";
      echo "<tr><td><b>Username: </b>$usernamestr</td></tr>";
      echo "<tr><td><b>Bug Report: </b>$messagestr</td></tr>";
      echo "<tr><td><b>Status: </b>$statusstr</td></tr>";
      echo "</table><p />";
    }
  }
}
?>

<div align="center">
<form method="GET" action="bugslist.php">
<input type="submit" name="fixed" value="Fixed Bugs">
<input type="submit" name="pending" value="Pending Bugs">
<p /><b>Select which type of bugs you would like to check.</b><p />
</div>

<?php include("templates/private_footer.php"); ?>

Link to comment
Share on other sites

If you're checking for <=2 for a redirect and your staff value is 4 then it won't redirect as 4 is not lower or equal to 2.

 

yes i know that ;)

 

its not redirecting people with lower or equal to 2 its staying on the bugslist.php page and only displaying

 

player->staff =0

Link to comment
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.