Monday, January 16, 2012

Pass an ID from a web url

 How to Pass an ID from a link :
We retrieve data or value of input type with a form and a submit button.
But some times we need to pass an id from a url....
For example user click link to visit the site or a common page but we need to find what link the user click or which link clicked.
Foe this reason we need to pas an ID with the link.
With this example we will found the solution.
Sample html Code : (test.html)
<html>
<body>
<a href=mypage.php?id=IamClicked.>Click me</a>
</html>
</body>
To find the ID or detect the link php Code : (mypage.php)
 <?php

if(isset($_GET['id']))
{
  print $_GET['id'];
}

?>
For multiple id


Sample html Code : (test2.html)
<html>
<body>
<a href=mypage2.php?id=IamClicked&id2=IamClickedToo>Click me</a>
</html>
</body>
Php Code for this multiple id : (mypage2.php)

<?php
if(isset($_GET['id'])&&isset($_GET['id2']))

{

  print $_GET['id'];

  print "<br>";

  print $_GET['id2'];
}
?>
This will help to build a dynamic web page...............

Thank you......

No comments:

Post a Comment