 |
 |
php header go back?
|
 |
|
 |
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
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
|
|
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]
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
or try this:
header("Location: " . $_SERVER['HTTP_REFERER']);
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |