Jump to content

url variable


fred asselyon
 Share

Recommended Posts

Is there any way to send a variable from a text link without a form?For example, I have a link here:

<a href="somefile.php">a hyperlink</a>

I've read something about an url variable (i think it's related to GET method)Is there any way that i can make this link opens the url AND send a variable to it so that it can be processed by the "somefile.php"? Let's say that I have a variable $var_string. Can I make the link send the variable to it? If I can, how should I name it? should i use the _GET thing?

Link to comment
Share on other sites

Have this:...href="somefile.php?var_string=value":)Then the file somefile.php gets the variable $var_string with value "value" :)You can retreive it there by $_GET['var_thing']Alternatively, copy the value into a loose variable, by extract($_GET),which creates the variable $var_string from $_GET['var_string']

Edited by Dan The Prof
Link to comment
Share on other sites

Yes you can, you should add more variables at the end of the url by using the ampersand ( & ) between the value of the last and the variablename of the next variable.A URL can look like this:

http://www.somesite.com/some_folder/filename.php?variable1=something&variable2=somethingelse&variable3=somethingmore
So if a query is added to the url, it begins with a questionmark ( ? ). If more variables are used, they should be separated by ampersands ( & ). :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...