Jump to content

linking to file but remove ?id=1


XeroXer

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?
Link to comment
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...
Link to comment
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]
Link to comment
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...
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.