URL syntax

in this example we have this url

www.htmlexample.org/phpexample.php

Before passing a variable using the url first add a '?' to the end of the normal url

www.htmlexample.org/phpexample.php?

after the ? add the name of the variable

www.htmlexample.org/phpexample.php?varName

put an "=" then add the value assigned to the variable name

www.htmlexample.org/phpexample.php?varName=value

to pass more then one variable repeat above but only have '?' before the first one and a '&' in between each new variable

www.htmlexample.org/phpexample.php?varName=value&othervarName=othervalue

Getting the variables

To get the variable values from the url use the $_GET method

for example to get the value of the variable varName use

$_GET["varName"]

use $_GET the same as any other method

Example

this is an example of passing a string variable tom and int variable 22 to the php script

then using the 2 variables in the webpage

www.htmlexample.org/phpexample.php?name=tom&age=22

echo "<h6>Name " . $_GET["name"] . "</h6>";

echo"<h6>Age " . $_GET["age"] . "</h6>";