1//There are three method to pass value in php.
2
3//By post
4//By get
5//By making session variable
6//These three method are used for different purpose.For example if we want to receive our value on next page then we can use 'post' ($_POST) method as:-
7
8$a=$_POST['field-name'];
9//If we require the value of variable on more than one page than we can use session variable as:-
10
11$a=$_SESSION['field-name];
12//Before using this Syntax for creating SESSION variable we first have to add this tag at the very beginning of our php page
13
14session_start();
15//GET method are generally used to print data on same page which used to take input from user. Its syntax is as:
16
17$a=$_GET['field-name'];
18//POST method are generally consume more secure than GET because when we use Get method than it can display the data in URL bar.If the data is more sensitive data like password then it can be inggeris.
1//Thanks for the answers above. Here's how I did it, I hope it helps those who follow. I'm looking to pass a registration number from one page to another, hence regName and regValue:
2
3//Create your first page, call it set_reg.php:
4
5<?php
6
7session_start();
8
9$_SESSION['regName'] = $regValue;
10
11?>
12
13<form method="get" action="get_reg.php">
14 <input type="text" name="regName" value="">
15 <input type="submit">
16</form>
17
18//Create your second page, call it get_reg.php:
19
20<?php
21
22session_start();
23
24$regValue = $_GET['regName'];
25
26echo "Your registration is: ".$regValue.".";
27
28?>
29
30<p><a href="set_reg.php">Back to set_reg.php</a>