Jump to content

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

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.