XeroXer Posted July 29, 2006 Share Posted July 29, 2006 [u][b]Hello![/b][/u]My guestbook is based on one file.Earlier today I got help regarding linking inside the file.Well now I need more help regarding that.Becuase people might wanna change the name of my file I added so it uses [color=red]$_SERVER[PHP_SELF][/color].At the start of the file I set [color=red]$gbpage[/color] to [color=red]$_SERVER[PHP_SELF][/color] and then in the file use it like this:[code]<?php echo $gbpage; ?>?id=1[/code]The problem comes if people go first to [color=red]id2[/color] and then fron there to [color=red]id4[/color].Then I want them to by one click or automatic refresh of the page get back to the start page.Let's say the file name is [color=red]index.php[/color]. Then they click a link to [color=red]index.php?id=2[/color] and from there [color=red]index.php?id=4[/color].Then I want the page to go back to [color=red]index.php[/color].But because I don't know what the filename is and [color=red]$_SERVER[PHP_SELF][/color] outputs [color=red]index.php?id=4[/color] I have a problem.Can I somhow use the [color=red]$_SERVER[PHP_SELF][/color] and remove the [color=red]?id=4[/color] automatic? Link to comment https://forums.phpfreaks.com/topic/15961-linking-to-file-but-remove-id1/ Share on other sites More sharing options...
AndyB Posted July 29, 2006 Share Posted July 29, 2006 off the top of my head ... try $_SERVER['SCRIPT_NAME'] Link to comment https://forums.phpfreaks.com/topic/15961-linking-to-file-but-remove-id1/#findComment-65560 Share on other sites More sharing options...
XeroXer Posted July 29, 2006 Author Share Posted July 29, 2006 How should I make that in a link?Because I use it in many places in the file I first det the function and then try to make it as a link:[code]<?php$gbpageother = "$_SERVER[SCRIPT_NAME]";?><meta http-equiv='refresh' content='3\;URL=$gbpageother'>You will be sent back in 3 seconds. If not click <a href='$gbpageother'>here</a>[/code]This may look stupid to you but then please clear it out.How should this be done?[b]EDIT:[/b]Added to the point is that the above example does not work... Link to comment https://forums.phpfreaks.com/topic/15961-linking-to-file-but-remove-id1/#findComment-65566 Share on other sites More sharing options...
Chetan Posted July 29, 2006 Share Posted July 29, 2006 its easy use this[code]<?php$gbpageother = "$_SERVER[SCRIPT_NAME]";?><meta http-equiv='refresh' content='3\;URL=<? echo $gbpageother ?>'>You will be sent back in 3 seconds. If not click <a href='<? echo $gbpageother; ?>'>here</a>[/code]incase you want ?id=4 then do this[code]<?php$gbpageother = "$_SERVER[SCRIPT_NAME]";?><meta http-equiv='refresh' content='3\;URL=<? echo $gbpageother ?>?id=4'>You will be sent back in 3 seconds. If not click <a href='<? echo $gbpageother; ?>?id=4'>here</a>[/code] Link to comment https://forums.phpfreaks.com/topic/15961-linking-to-file-but-remove-id1/#findComment-65571 Share on other sites More sharing options...
XeroXer Posted July 29, 2006 Author Share Posted July 29, 2006 ok...how about if I am setting that text as a $ then?[code]$gbedited = "<meta http-equiv='refresh' content='3\;URL=$gbpageother'>Click <a href='$gbpageother'>here</a>";[/code]Because I use that text multiple times to... Link to comment https://forums.phpfreaks.com/topic/15961-linking-to-file-but-remove-id1/#findComment-65577 Share on other sites More sharing options...
Chetan Posted July 30, 2006 Share Posted July 30, 2006 [quote author=XeroXer link=topic=102253.msg405579#msg405579 date=1154199619]ok...how about if I am setting that text as a $ then?[code]$gbedited = "<meta http-equiv='refresh' content='3\;URL=$gbpageother'>Click <a href='$gbpageother'>here</a>";[/code]Because I use that text multiple times to...[/quote][code]$gbedited = "<meta http-equiv='refresh' content='3;URL=$gbpageother'>Click <a href='$gbpageother'>here</a>";[/code]u dun escape ; ok so it should work Link to comment https://forums.phpfreaks.com/topic/15961-linking-to-file-but-remove-id1/#findComment-65728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.