Problem v PHP adminu

Lep pozdrav.

Pred kratkim so mi eni mozje sprogramiral stran in tud admin ki je v php-ju. Imam naslednji problem:

Na strani imam admin, kjer so clani strani. Na managetitan.php je liste vseh clanov(10 na stran), kjer je tudi opcija edit(edittitan.php), kjer spreminjam njihove statuse(pending,approved,declined). Problem je naslednji:
Recimo da odprem stran 5 in kliknem na clana XXX -edit(edit_titan.php?id=xxx) , kjer nastvim njegov status in kliknem "Submit". Ko je status spremenjen, me vedno po tem vrne na stran 1. Rad bi pa naredil tako da ko spremenim temu uporabniku status, da me vrze nazaj na istro stran kjer je leta bil(v tem primeru stran 5). Ce kdo ve kako se to naredi, bi bil zelo hvalezen ce lahko opise.

13 odgovorov

Najlažje je, da si v linku na seznamu še povsod dodajaš edit_titan.php?id=xxx&izStrani=x in potem se vrne na ta x. Samo če imaš funkcijo različnih razvrstitev seznama, moreš upoštevati še to.

B]manage_titan.php:

<?
ob_start();
include"header.php";

$no=1;
$sp=0;

$qpage="select *, titan.date as display_date  from titan, member
WHERE titan.member_id=member.member_id
order by titan_id";
$rs_page=mysql_query($qpage);
$cnt=mysql_num_rows($rs_page);
$totalpage=ceil($cnt/10);

if(isset($_GET['pageno']))
   $no=$_GET['pageno'];
$sp=($no*10)-10;

if(!$by) {
   $by = 'titan_id';
}
//echo $sortby;
$sql="SELECT *, titan.date as display_date, titan.status as display_status FROM titan, member
WHERE titan.member_id=member.member_id
order by $by $sort
limit $sp,10 ";

//$sql= "select * from site_user where type!='admin'order by pk_id limit $sp,10";
$result=mysql_query($sql);
?><head>
<script>
function chkDel(getId)
{
   if(confirm("Are you sure want to delete this user?"))
   {
      location.href="delete_titan.php?id="+getId;
   }
}
</script>
</head>            <table align="center" border="0" cellpadding="0" cellspacing="0" width="850">
            <tbody><tr>
               <td class="border" bgcolor="#ffffff" valign="top" width="850"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="196" align="left" valign="top"><?
include"left_nav.php";
?></td>
                        <td valign="top">
                  <form name="form" action="crm_submit.php" enctype="multipart/form-data" method="post">
                          <table align="center" bgcolor="#ffffff" border="0" cellpadding="2" cellspacing="2" width="95%">
                          <tbody>
                            <tr>
                              <td valign="top" bgcolor="#666666"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td><span class="style3"><strong>Manage Titan Poker </strong></span></td>
                                  <td><div align="right"><a href="add_customer.php" class="menu"></a></div></td>
                                </tr>
                              </table></td>
                            </tr>
                            <tr>
                              <td valign="top" width="68%"><table width="100%"  border="0" class="buttons" align="center" cellspacing="1" bgcolor="#f5f5f5" style="border:#999999 solid 1px;">
                          <tr align="left" valign="middle">
                             <?

                     if($sort=="asc")
                     {
                        $newsort = 'desc';
                     } else {
                        $newsort ="asc";
                     }
                     ?>
                            <td width="11%" height="23" >Sl.No.</td>
                            <td width="15%" >
                                 <a href="manage_titan.php?sort=<? echo $newsort; ?>&by=titan_username">Titan User Name</a>
                            </td>
                            <td width="18%" >
                               <a href="manage_titan.php?sort=<? echo $newsort; ?>&by=titan_name">Titan Screenname</a>
                            </td>
                            <td width="16%" >
                        <a href="manage_titan.php?sort=<? echo $newsort; ?>&by=titan_email">Titan Email</a>
                     </td>
                     <td width="16%" >
                        <a href="manage_titan.php?sort=<? echo $newsort; ?>&by=titan.date">Date</a>
                     </td>
                            <td width="11%" >
                               <a href="manage_titan.php?sort=<? echo $newsort; ?>&by=member_email">Username</a>
                     </td>
                     <td width="11%" >
                        <a href="manage_titan.php?sort=<? echo $newsort; ?>&by=ip">Ip</a>
                     </td>
                     <td width="11%" >
                        <a href="manage_titan.php?sort=<? echo $newsort; ?>&by=titan.status">Status</a>
                     </td>
                            <td width="11%" >Action</td>
                          </tr>
                          <?
                    $i=0;
  while ($rs = mysql_fetch_array($result))
{
$i++;
   if($i%2 == 0)
      $bgcolor = "#f6f6f6";
   else
      $bgcolor = "#DBDBDB";
?>
                          <tr>
                            <td class="bodytext" bgcolor="<?=$bgcolor?>" height="23">
                                 <?=$i;?>.                            </td>
                            <td class="bodytext" bgcolor="<?=$bgcolor?>">
                                <?=$rs['titan_username'];?>                            </td>
                            <td class="bodytext" bgcolor="<?=$bgcolor?>">
                                      <?=$rs['titan_name'];?>                  </td>
                            <td width="16%" class="bodytext" bgcolor="<?=$bgcolor?>">
                               <a href="mailto:<?=$rs[titan_email]?>"> <?=$rs['titan_email'];?></a></td>
                       <td width="16%" class="bodytext" bgcolor="<?=$bgcolor?>">
                               <?=$rs['display_date'];?></td>

                            <td width="11%" bgcolor="<?=$bgcolor?>">
                     <?
                  //$member_id=$rs['member_id'];
                  //$sql_site="select * from member where member_id=$member_id";
                  //$result_site=mysql_query($sql_site);
                  //$rs_site=mysql_fetch_array($result_site);
                     ?><a href="view_customer.php?id=<?=$rs['member_id'];?>"><? echo $rs['member_email'];?></a></td>
                     <td width="16%" class="bodytext" bgcolor="<?=$bgcolor?>">
                               <?=$rs['ip'];?></td>
                      <td width="16%" class="bodytext" bgcolor="<?=$bgcolor?>">
                               <?
                           if($rs['display_status']==1)
                              echo "Accepted";
                           else if($rs['display_status']==2)
                              echo "Declined";
                           else
                           echo"Pending";
                        ?></td>

                            <td width="11%"  class="bodytext" bgcolor="<?=$bgcolor?>"><a class="red_small_links" href="edit_titan.php?id=<?=$rs['titan_id'];?>">Edit</a>
                              /<a class="red_small_links" href="#" onClick="chkDel('<?=$rs[titan_id]?>');">
                              Delete </a></td>
                          </tr>
                          <?
     }

?>
                        </table></td>
                            </tr>
                            <tr>
                              <td valign="top" align="center">
                         Pages
                        <?

if($totalpage > 9) {
               if(!isset($_GET['pageno'])) {
                     $_GET['pageno'] = 1;
               }
               if($_GET['pageno'] <> 1) {
                  echo" <a href='manage_titan.php?" . "sort=" . $sort . "&by=" . $by . "&pageno=" . ($_GET['pageno'] - 1) . "' class='bodytext'>Previous</a>";
                  echo" <a href='manage_titan.php?" . "sort=" . $sort . "&by=" . $by . "&pageno=1' class='bodytext'><<</a>";
               }

               if($_GET['pageno'] > 4 AND $_GET['pageno'] < $totalpage-4) {
                     for($i=$_GET['pageno']-4;$i<=$_GET['pageno']+4;$i++)
                     {
                  if($i==@$_GET['pageno'])
                  {
                      echo $_GET['pageno'];

                  }
                  else
                  {
                     echo" <a href='manage_titan.php?" . "sort=" . $sort . "&by=" . $by . "&pageno=$i' class='bodytext'>".$i."</a>";
                  }
               }
               } else if($_GET['pageno'] <= 4) {
                     for($i=1;$i<=9;$i++)
                     {
                  if($i==@$_GET['pageno'])
                  {
                      echo $_GET['pageno'];

                  }
                  else
                  {
                     echo" <a href='manage_titan.php?" . "sort=" . $sort . "&by=" . $by . "&pageno=$i' class='bodytext'>".$i."</a>";
                  }
               }
            } else if($_GET['pageno'] >= $totalpage-4) {
                     for($i=$totalpage-8;$i<=$totalpage;$i++)
                     {
                  if($i==@$_GET['pageno'])
                  {
                      echo $_GET['pageno'];

                  }
                  else
                  {
                     echo" <a href='manage_titan.php?" . "sort=" . $sort . "&by=" . $by . "&pageno=$i' class='bodytext'>".$i."</a>";

                  }
               }

               }

               if($_GET['pageno'] <> $totalpage) {
               echo" <a href='manage_titan.php?" . "sort=" . $sort . "&by=" . $by . "&pageno=" . ($totalpage) . "' class='bodytext'>>></a>";

                  echo" <a href='manage_titan.php?" . "sort=" . $sort . "&by=" . $by . "&pageno=" . ($_GET['pageno'] + 1) . "' class='bodytext'>Next</a>";
               }

} else {
///-----------------------------------
for($i=1;$i<=$totalpage;$i++)
{
if($i==@$_GET['pageno'])
      {
    echo $_GET['pageno'];

      }
else
      {
      echo" <a href='manage_titan.php?" . "sort=" . $sort . "&by=" . $by . "&pageno=$i' class='bodytext'>".$i."</a>";
      }
}
///-----------------------------------
}
?></td>
                            </tr>
                          </tbody>
                        </table>
                  </form></td>
                      </tr>
                    </table></td>
               <td background="images/right.jpg" width="9"><div align="right"></div>
               </td>
            </tr>
            <tr>
               <td colspan="2"> </td>
            </tr>
         </tbody></table>

<?
include"footer.php";
?>

edit_titan.php:

<?
ob_start();
include"header.php";
$id=$HTTP_GET_VARS['id'];

if($id)
{
$sql="SELECT * FROM titan WHERE titan_id='$id'";
  $result=mysql_query($sql);
  $rs=mysql_fetch_array($result);
}
if($_POST['edit_usr'] == "Update")
{
   $titan_id=$_POST['titan_id'];
   $titan_username=$_POST['titan_username'];
   $titan_screenname=$_POST['titan_screenname'];
   $titan_email=$_POST['titan_email'];
   $status=$_POST['status'];
   $sql = "update titan SET  titan_username='$titan_username', titan_name='$titan_screenname', titan_email='$titan_email',status = '$status' where titan_id = '$titan_id'";
  $result=mysql_query($sql);

   $_SESSION['sess_msg'] = "User Information Updated Successfully.";
   header("Location: manage_titan.php");
   exit;
}
?>            <table align="center" border="0" cellpadding="0" cellspacing="0" width="750">
            <tbody><tr>
               <td class="border" bgcolor="#ffffff" valign="top" width="750"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="25%" align="left" valign="top"><?
include"left_nav.php";
?></td>
                        <td valign="top">
                  <form name="form" action="" enctype="" method="post">
                          <table align="center" bgcolor="#ffffff" border="0" cellpadding="2" cellspacing="2" width="95%" style="border:#999999 1px solid;">
                          <tbody>
                            <tr>
                              <td valign="top" bgcolor="#666666"><span class="style3">Manage Customer </span></td>
                            </tr>
                            <tr>
                              <td valign="top" width="68%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="25%"><div align="center"><strong>Titan User  Name:</strong></div></td>
                                  <td width="25%">
                                    <label>
                                    <input name="titan_username" type="text" id="titan_username" value="<?=$rs['titan_username'];?>" size="18" />
                           <input name="titan_id" type="hidden" value="<?=$rs['titan_id'];?>" />
                                  </label></td>
                                </tr>
                                <tr>
                                  <td><div align="center"><strong>Titan Screen Name :</strong></div></td>
                                  <td>
                                  <input name="titan_screenname" type="text" id="titan_screenname" value="<?=$rs['titan_name'];?>" size="18"/></td>
                                </tr>
                                <tr>
                                  <td><div align="center"><strong>Titan Email: </strong></div></td>
                                  <td>
                          <input name="titan_email" type="text" id="titan_email" value="<?=$rs['titan_email'];?>" size="18"/></td>
                                </tr>
                                                          <tr>
                                  <td><div align="center"><strong>Status:</strong></div></td>
                                  <td> <select name="status" class="buttons"><?
                                   if($rs[status]==1)
                                 {
                                ?>
                                              <option value="1">Approved</option>
                                              <option value="0">Pending</option>
                                   <option value="2">Declined</option>
                                              <?
                                   }
                                 else if($rs[status]==0)
                                 {
                                 ?> <option value="0">Pending</option>
                                             <option value="1">Approved</option>
                                   <option value="2">Declined</option>
                                              <?
                                 }else
                                 {
                                ?><option value="2">Declined</option>
                                   <option value="0">Pending</option>
                                             <option value="1">Approved</option>

                                   <?
                                   }
                                   ?>
                                            </select>                                </td>

                                </tr>

                                <tr>
                                  <td> </td>
                                  <td><input type="submit" name="edit_usr" value="Update" class="buttons" /></td>
                                </tr>
                              </table></td>
                            </tr>
                            <tr>
                              <td valign="top" align="center"> </td>
                            </tr>
                          </tbody>
                        </table>
                  </form></td>
                      </tr>
                    </table></td>
               <td background="images/right.jpg" width="9"><div align="right"></div>
               </td>
            </tr>
            <tr>
               <td colspan="2"> </td>
            </tr>
         </tbody></table>

<?
include"footer.php";
?>

Hmm

tole:

header("Location: manage_titan.php");

zamenjaš s:

if (isset($_GET['pageno']) && is_numeric($_GET['pageno']))
{
    header("Location: manage_titan.php?pageno=".$_GET['pageno']);
}
else
{
    header("Location: manage_titan.php");
}

nisem pa preiskusil in nevem če sem vzel prave spremenljivke ... to bo Vini z eno oko pogledal pa povedal če bo delalo :D.

<?
ob_start();
include"header.php";
$id=$HTTP_GET_VARS['id'];

if($id)
{
$sql="SELECT * FROM titan WHERE titan_id='$id'";
  $result=mysql_query($sql);
  $rs=mysql_fetch_array($result);
}
if($_POST['edit_usr'] == "Update")
{
   $titan_id=$_POST['titan_id'];
   $titan_username=$_POST['titan_username'];
   $titan_screenname=$_POST['titan_screenname'];
   $titan_email=$_POST['titan_email'];
   $status=$_POST['status'];
   $sql = "update titan SET  titan_username='$titan_username', titan_name='$titan_screenname', titan_email='$titan_email',status = '$status' where titan_id = '$titan_id'";
  $result=mysql_query($sql);

   $_SESSION['sess_msg'] = "User Information Updated Successfully.";

// TOLE MISLIM:
 header("Location: manage_titan.php");

   exit;
}

pa raje prej naredi kopijo datoeke v primeru da ne dela ...

Tole sem spremenil v edit_titan.php in problem se vedno ostaja.

lp

Mah lahko puskusiš še tole dodati, vendar mi ni jasno zakaj bi spremenljivka izginila iz naslova ...

[HTML]<form name="form" action="" enctype="" method="post">[/HTML]

v

<form name="form" action="<?

if (isset($_GET['pageno']) && is_numeric($_GET['pageno']))
{
    echo "edit_titan.php?pageno=".$_GET['pageno'];
}
else
{
    echo "edit_titan.php";
}

?>" enctype="" method="post">

Sem spremenil tudi to, ampak še vedno ne dela.

A to dodajam samo v edit_titan.php?

lp

Ja, sej drugih datotek nisi pokazal ...

am to v edit_titan.php je samo spreminjanje spremenljivk ali seznam sam tudi ? Potem bi moral še spremeniti v tisti datoteki, s katere prideš na to datoteko.

V 1. in 2. postu je managetitan.php v 3. a edittitan.php

Kaj je potem potrebnos premenit pri m_t