All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

How To Pass Parameter In URL In PHP

Last Updated : Mar 11, 2024

How To Pass Parameter In URL In PHP

In this tutorial we will show you the solution of how to pass parameter in URL in PHP, passing parameters in URL is a very tricky part. In PHP, developers used to pass parameters in URL when they use redirections.

For example, let there is a list of student’s sorts by there class and from that list of students we just want to retrieve information of a particular students by clicking on his/her name, so for this we just send student’s unique id to another page at which id is retrieved from another page a data will be shown with help of id and database.

So, today we are here to understand how to pass parameters in URL in PHP.

Step By Step Guide On How To Pass Parameter In URL In PHP :-

Now, as we already understand why we need parameters in URL in php and what is there use.

So, after this let us see how to pass parameters in URL in php with the help of example given below.

<!DOCTYPE html>
<html>
<head>
   <title> how to pass parameters in URL in php</title>
</head>
<body>
<a href=”next_page.php?value=<?php echo “TalkersCode is here” ?>”> Click on this link to send value </a>
</body>
</html>
Next_page.php
<!DOCTYPE html>
<html>
<head>
   <title> fetching parameters from url </title>
</head>
<body>
 <?php
  echo $_GET[‘value’];
 ?>
</body>
</html>
  1. As, here we see that we that in above example we show you an example in which HTML and PHP codes are used.
  2. Here, first of all, we create a basic structure of HTML, in which we use <!DOCTYPE html> which defines the type of document. And next one is our HTML tags. These tags are paired tags and all the data regarding HTML is written inside these tags.
  3. After we use our head tag which is again paired tag and contains the title and meta information of the webpage. The data written inside the head is not shown on the webpage.
  4. Now, next is our title tag which defines the title of the webpage. The tag which has its closing tag is known as a paired tag. So, this is again a paired tag.
  5. Now, next is the body which is the main tag of HTML. The data which we have written inside the body is shown on the webpage. Mostly all tags which are helpful to show data or information on the screen are written under the body tag.
  6. Now, as we see in first page in which we send parameters, we just use anchor tag which help us to both send parameters and help to redirect user to next page.
  7. Whereas in next page we just fetch the parameters with help of get method used in PHP, and echo to show that parameter gets fetched by next page.
  8. This also helps to do CRUD operations in PHP. We use this method mostly in deletion and updating time.

Conclusion :-

At last, in conclusion, here we can say that with the help of this article we can understand how to pass parameters in URL in PHP.

I hope this tutorial on how to pass parameter in URL in PHP helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Ashish

Ashish is a dynamic and motivated individual with a passion of programming and an experienced programmer having 3+ years of experience in various languages like Java, Python, HTML, CSS, JavaScript, jQuery and various frameworks like Bootstrap

Follow Ashish On Linkedin 🡪