'How to use php _GET?
I am asking two things.
The first question is am I doing this correctly? I am putting together a link with javascript variables
http://google.com/test.php?var="+class4And then I am using php to get the values of the variables from the URL
Can I use a link at all to do the variables or must I use a button? When using the link nothing shows in the url after the
?.
Solution 1:[1]
To make the link you'd need to do something like
var link = "http://google.com/test.php?class=" + "class4";
To go there you would do something like
location.href = link;
And in the PHP code to get the value, you would do something like
$class = $_GET['class'];
Solution 2:[2]
Link should look like http://google.com/test.php?var=class4 (There is no need for quotes or +)
then you can do echo $_GET['var'];
Solution 3:[3]
hmm what dou you get out of this :
var url = 'http://google.com/test.php?var='+class4;
alert(url);
Assuming 'class4' is an variable in javascript you have created. otherwise
var url = 'http://google.com/test.php?var=class4';
alert(url);
Does this give you the url you are wanting to redirect to ?
if so try to copy paste the alert from the alert into the browsers adresbar and test if it works
in the php page just after
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | McKayla |
| Solution 2 | amosrivera |
| Solution 3 | DonSeba |
