horsovski Posted October 12, 2007 Share Posted October 12, 2007 Hello Im not familiar with php, but i have this problem on my website. Its in the admin of the website and its the part where i see my members( 10 per page) and change their status(pending,approved,declined). Now the problem: For example i go to page 6 and choose member XXX - then im taken to this edit php page where i can change his status and click "Sumbit" But when i click on submit, his status gets changed and all, but after that it takes me to page 1 always. Id like to have it that that when i click on submit and his status gets changed it takes me back to previous page, in this example page 6. What do i need to change here to fix my problem? Thanks in advance Here is the code: <? 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/ Share on other sites More sharing options...
Aureole Posted October 12, 2007 Share Posted October 12, 2007 Well when you go to manage a user have the page you were on send to the management page using $_GET... e.g. list_users.php?page=3 So then you click on a user's manage link and it would take you to manage_user.php?id=x&frompage=3 x being the member's id. Then when you click submit have it so it takes you back to list_users.php?page=3 something like... after processing your form it'd be like: header('Location: list_users.php?page='.$_GET['frompage'].''); Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-367768 Share on other sites More sharing options...
horsovski Posted October 12, 2007 Author Share Posted October 12, 2007 Hm so now ive changed on edit_titan.php header("Location: manage_titan.php"); to header('Location: list_users.php?page='.$_GET['frompage'].''); But i dont understand the other part what else i have to do and on what php file exactly. For previous example First pagei click is manage_titan.php?sort=&by=titan_id&pageno=6 and then when i choose Edit its edit_titan.php?id=85 I dont understand what else i have to change and where. Here is also the code for 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-367777 Share on other sites More sharing options...
Aureole Posted October 12, 2007 Share Posted October 12, 2007 When you choose edit instead of the link being: edit_titan.php?id=85 It would need to be edit_titan.php?id=85&frompage=$_GET['page'] $_GET['page'] being the current page. Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-367780 Share on other sites More sharing options...
horsovski Posted October 12, 2007 Author Share Posted October 12, 2007 Thanks for fast answers. Ok so in manage_titan.php i have found 3 php?id : 1. location.href="delete_titan.php?id="+getId; 2. <a href="view_customer.php?id=<?=$rs['member_id'];?>"><? echo $rs['member_email'];?></a> 3. <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> So what exactly i need to change here and to what? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-367785 Share on other sites More sharing options...
Aureole Posted October 12, 2007 Share Posted October 12, 2007 How come they start with the a tag and end with [/url] ??? Anyway... <a class="red_small_links" href="edit_titan.php?id=<?=$rs['titan_id'];?>&frompage=<?=$_GET['page'];?>">Edit</a> That should work. Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-367788 Share on other sites More sharing options...
horsovski Posted October 12, 2007 Author Share Posted October 12, 2007 Hmm i have changed that line on manage_titan.php now but it still wont work. After i click on "Submit" it opens edit_titan.php?id=103&frompage= but his page cannot be displayed in ie(404) Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-367792 Share on other sites More sharing options...
horsovski Posted October 12, 2007 Author Share Posted October 12, 2007 Any help with this please ? Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-368002 Share on other sites More sharing options...
darsh999 Posted October 12, 2007 Share Posted October 12, 2007 When you choose edit instead of the link being: edit_titan.php?id=85 It would need to be edit_titan.php?id=85&frompage=$_GET['page'] $_GET['page'] being the current page. 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"; ?> In this i can find many mistakes in programming if the programing in incorrect how can you make a software or anything... Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-368042 Share on other sites More sharing options...
horsovski Posted October 12, 2007 Author Share Posted October 12, 2007 software works fine, i would just need to have this options aswell. Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-368044 Share on other sites More sharing options...
Aureole Posted October 12, 2007 Share Posted October 12, 2007 darsh999 that reply was un-needed... Quote Link to comment https://forums.phpfreaks.com/topic/72929-php-script-problem/#findComment-368052 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.