The list of all PHP and Mysql 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"

2 comments:

  1. Excellent blog, I wish to share your post with my folks circle. It’s really helped me a lot, so keep sharing post like this
    Selenium Training in Chennai | Selenium Training in Bangalore | Selenium Training in Pune

    ReplyDelete
  2. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. 먹튀검증

    ReplyDelete