Jump to content


Photo

linking to file but remove ?id=1


  • Please log in to reply
5 replies to this topic

#1 XeroXer

XeroXer
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts
  • LocationSweden

Posted 29 July 2006 - 06:08 PM

Hello!

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 $_SERVER[PHP_SELF].
At the start of the file I set $gbpage to $_SERVER[PHP_SELF] and then in the file use it like this:
<?php echo $gbpage; ?>?id=1

The problem comes if people go first to id2 and then fron there to id4.
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 index.php. Then they click a link to index.php?id=2 and from there index.php?id=4.
Then I want the page to go back to index.php.
But because I don't know what the filename is and $_SERVER[PHP_SELF] outputs index.php?id=4 I have a problem.

Can I somhow use the $_SERVER[PHP_SELF] and remove the ?id=4 automatic?
// XeroXer

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 29 July 2006 - 06:21 PM

off the top of my head ... try $_SERVER['SCRIPT_NAME']
Legend has it that reading the manual never killed anyone.
My site

#3 XeroXer

XeroXer
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts
  • LocationSweden

Posted 29 July 2006 - 06:31 PM

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:

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

This may look stupid to you but then please clear it out.
How should this be done?


EDIT:
Added to the point is that the above example does not work...
// XeroXer

#4 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 29 July 2006 - 06:56 PM

its easy use this
<?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>
incase you want ?id=4 then do this
<?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>

I am a PHP Guru, ask me questions if you want to

#5 XeroXer

XeroXer
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts
  • LocationSweden

Posted 29 July 2006 - 07:00 PM

ok...
how about if I am setting that text as a $ then?
$gbedited = "<meta http-equiv='refresh' content='3\;URL=$gbpageother'>Click <a href='$gbpageother'>here</a>";


Because I use that text multiple times to...
// XeroXer

#6 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 30 July 2006 - 05:11 AM

ok...
how about if I am setting that text as a $ then?

$gbedited = "<meta http-equiv='refresh' content='3\;URL=$gbpageother'>Click <a href='$gbpageother'>here</a>";


Because I use that text multiple times to...


$gbedited = "<meta http-equiv='refresh' content='3;URL=$gbpageother'>Click <a href='$gbpageother'>here</a>";

u dun escape ; ok so it should work
I am a PHP Guru, ask me questions if you want to




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users