Jump to content

variables in links


shadowmonk

Recommended Posts

Hi, I know there is another thread on here that is along these lines, but this one is different, trust me.

 

I have a link that is already passing variables, my problem is trying to add onto the link. If i use the $_SERVER['PHP_SELF'] variable I only get up to the filename. If I use the # sign in the href tag I get the whole link, but I can't append a variable to it.

 

Is this possible or do I need to create multiple links based on what variables are present?

Link to comment
https://forums.phpfreaks.com/topic/52033-variables-in-links/
Share on other sites

I don't think urlencode() will work, based on how I'm understanding the documentation and examples.

 

Let me try to clarify my problem with examples-

 

say my link is already: http://mysite.com/script.php?var=rand

 

What I'm trying to do is using a link within the page to append "&var2=foobar"

 

If I use the php_self I just get: http://mysite.com/script.php&var2=foobar

If I use # in the href it's: http://mysite.com/script.php?var=rand#&var2=foobar

 

The # is close, but it is looking for a link titled "&var2=foobar" somewhere on the page instead of passing it to the script as a variable. I was thinking the javascript this.href might work, but I can't figure out how to get it to work.

Link to comment
https://forums.phpfreaks.com/topic/52033-variables-in-links/#findComment-256490
Share on other sites

Archived

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

×
×
  • 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.