Jump to content

Archived

This topic is now archived and is closed to further replies.

XeroXer

linking to file but remove ?id=1

Recommended Posts

[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?

Share this post


Link to post
Share on other sites
off the top of my head ... try $_SERVER['SCRIPT_NAME']

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.