fred asselyon Posted December 17, 2005 Share Posted December 17, 2005 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 More sharing options...
Jack McKalling Posted December 17, 2005 Share Posted December 17, 2005 (edited) 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 December 17, 2005 by Dan The Prof Link to comment Share on other sites More sharing options...
fred asselyon Posted December 18, 2005 Author Share Posted December 18, 2005 What if i want to send few variables? Can I? Link to comment Share on other sites More sharing options...
Jack McKalling Posted December 18, 2005 Share Posted December 18, 2005 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=somethingmoreSo 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 More sharing options...
fred asselyon Posted December 18, 2005 Author Share Posted December 18, 2005 Great! Problem solved. Thanks for your help! Link to comment Share on other sites More sharing options...
Jack McKalling Posted December 18, 2005 Share Posted December 18, 2005 Anytime Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now