Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > php header go back?

php header go back?
Thread Tools
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Aug 7, 2005, 08:37 PM
 
i am scripting a really complicated to explain to you guys php script

i have a switch set up to change something on or off in mysql database

but i want it after it is done with that to back them up to there previous page so they never really leave the page they were on.

reason i need this is because the script i am working on is using phpnuke and i got a block were the variables are changed and the links go to that switch.


i know of these 2 headers
Code:
Header("Location: URLHERE");
and of
Code:
Header("refresh: #; url= URLHERE");
     
Mac Elite
Join Date: Mar 2002
Location: Clogland
Status: Offline
Reply With Quote
Aug 8, 2005, 05:38 AM
 
Not really sure what you mean, but if the "switch" is attached to some sort of <a href.... you could do something like this.

<a href="same_url?action=bla>switch</a>

Then on the page have...

[php]
if(bla==$action){
do whatever;
unset($action);
}
[/php]
     
jay3ld  (op)
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Aug 8, 2005, 11:01 AM
 
yea thats what i have


you can see at bottom i go 2 switchs with 2 cases in each. now after each one is done i want it to take it to the last page they were on and refresh.


Code:
OpenTable(); echo "<h2>Show/Hide Online and Hits</h2>" ."<table><tr><td algin=right>" ."Hide/Show Online:" ."</td><td algin=left>" ."<a href=modules.php?name=SBlock&file=admin&ShowOnline=On>On</a> : <a href=modules.php?name=SBlock&file=admin&ShowOnline=Off>Off</a>" ."</td></tr><tr><td algin=right>" ."Hide/Show Page Hits:" ."</td><td algin=left>" ."<a href=modules.php?name=SBlock&file=admin&PageHits=On>On</a> : <a href=modules.php?name=SBlock&file=admin&PageHits=Off>Off</a>" ."</td></td></tr></table>"; CloseTable(); switch($ShowOnline) { case "Off": $sql = "UPDATE ".$prefix."_SBlock set Show_WhosOnline = '0'"; $db->sql_query($sql); Header ("Location: modules.php?name=SBlock&file=admin&Settings=Updated"); break; case "On": $sql = "UPDATE ".$prefix."_SBlock set Show_WhosOnline ='1'"; $db->sql_query($sql); Header ("Location: modules.php?name=SBlock&file=admin&Settings=Updated"); break; } switch($ShowPageHits) { case "Off": $sql = "UPDATE ".$prefix."_SBlock set Show_PageHits = '0'"; $db->sql_query($sql); Header ("Location: modules.php?name=SBlock&file=admin&Settings=Updated"); break; case "On": $sql = "UPDATE ".$prefix."_SBlock set Show_PageHits ='1'"; $db->sql_query($sql); Header ("Location: modules.php?name=SBlock&file=admin&Settings=Updated"); break; }
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Aug 8, 2005, 11:01 AM
 
Code:
Header("Location: URLHERE");
Looks good to me. Easiest way is to use your $_SERVER superglobal:-

header("Location: {$_SERVER['SCRIPT_NAME']}");
Computer thez nohhh...
     
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
Aug 8, 2005, 11:34 AM
 
don't forget an "exit;" after the header redirect. If you just redirect the user, the script will continue to execute to its completion (even though the user has been redirect). This can be handy in certain situations (such as maybe a script that takes a bit to run so you redirect the user to a landing page to check/wait for the script to complete); but in most cases, it is probably not desired to let it keep running after redirecting a user.
The only thing necessary for evil to flourish is for good men to do nothing
- Edmund Burke
     
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Aug 10, 2005, 08:30 AM
 
or try this:

header("Location: " . $_SERVER['HTTP_REFERER']);
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:24 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2