I am discussing How to pass parameters as type GET to another page. OR Pass parameters as GET without using a form.OR Pass parameters through URL.
When we are using a form of method GET the values of text boxes enclosed in the form are
send to the action page through the URL.We can also send values through URL without a form.
If we want to pass a variable to another page when click a link
If we want to pass more than 1 values seperate them with ' & '.
In target.php the values can be retrieved just like form values send as GET method.
That is
$n1=5;
?>
<a href="target.php?n1=<?php echo $n1 ;?>">Click Here</a>
echo $_GET["n1"];
?>
You can see these two examples of using this method here :-
Change font size of text in HTML page dynamically using php
When we are using a form of method GET the values of text boxes enclosed in the form are
send to the action page through the URL.We can also send values through URL without a form.
If we want to pass a variable to another page when click a link
<a href="target.php?n1=5">Click Here</a>
If we want to pass more than 1 values seperate them with ' & '.
<a href="target.php"?n1=5&n2=10&name=sbr>Click Here</a>
In target.php the values can be retrieved just like form values send as GET method.
That is
$n1=$_GET["n1"];
$n2=$_GET["n2"];
$name=$_GET["name"];
$n2=$_GET["n2"];
$name=$_GET["name"];
When we want to send values of php variables , these code may be helpful
1.Pass a single value to another page
t1.php
<?php$n1=5;
?>
<a href="target.php?n1=<?php echo $n1 ;?>">Click Here</a>
target.php
<?phpecho $_GET["n1"];
?>
2.Pass more than one value to another page
t1.php
target.php
<?php
echo $_GET["n1"];
echo $_GET["n2"];
?>
<?php
$n1=5;
$n2=7;
?>
<a href="target.php?n1=<?php echo $n1 ;?>&n2=<?php echo $n2;?>">Click Here</a>
target.php
<?php
echo $_GET["n1"];
echo $_GET["n2"];
?>
You can see these two examples of using this method here :-
Change font size of text in HTML page dynamically using php
Hope that this post is helpful to you.
By Sukesh B R
No comments:
Post a Comment