Categories
php

PHP: Passing Variables from One Page to Another

There are two methods by which one can pass variables from one page to another. One is GET method and the other is POST method.
In GET method we pass the variables and their value in the url like

[php]

http://urtl.com/video.php?var1=xxx&var2=xxx2

[/php]

etc and you fetch the variables using $_GET

[php]

$title = $_GET[“var1”];
$title2 = $_GET[“var2”];

[/php]

Post method is used in form. When form is submitted the values are passed from the text fields to the destination page. We retrieve the values as

[php]

$title = $_POST[“varl1”];

[/php]

where var1 is the name or id of the form text element or the element of the form which contains specific data we are requesting.