The list of all PHP and Mysql posts

Showing posts with label POST method. Show all posts
Showing posts with label POST method. Show all posts

How to add a variable to URL adress

It's a very effective trick to play with the $_GET variables in url address.
As we all know , the internet uses two ways to send variables from a page to an other one :
1. POST 2. GET

All of the variables in a webpage are sent in a universal array in the form of $_GET or $_POST. There is a different between these two methods. GET method attaches the variables to the end of the url address but POST method sends the variables hidden and more protected , so it's recommended to send the username and password variables by POST method.

You can add variables directly to url address , in fact you act as if  you pass them by GET method manually.
For example :
the following html shows a link to an other page.

code:
<a href = "showtopic.php"> title of the topic</a>

If you want to redirect the user to a common page that shows a content depend on a variable that is received through link , you can use the following php code.

code:

$TextTitle = "title of the topic";
$Textlink = "a string that is specified to recognize  the requested content";
echo "<a href=\"showtopic.php?Textlink=" .$Textlink. " \">" . $TextTitle . "</a>";

This code is an active link. It redirets the user to "showtopic.php" page . it also sends "Textlink" variable to the page , so the server decides base on the variable to show the appropriate content.

So to add a variable to an adress just add a  ?  sign to its end and then type the variable name ,  = sign and the variable content:

url adress ? variable name = "variable content"