All TalkersCode Topics

Follow TalkersCode On Social Media

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

Get And Post Method In PHP

Last Updated : Mar 11, 2024

Get And Post Method In PHP

In this tutorial we will show you the solution of get and post method in PHP, today we are going to understand what are get and post method and what the difference between them is.

We hope that you all know where get and post methods are used. If not, then one thing to note here that they are used in forms whether it is in html or in php. Now, let us understand get and post method.

Step By Step Guide On Get And Post Method In PHP :-

Here, today we are going to understand what are get and post methods.

These both are ways to submit data from form. You have to specify which method you want to use. Now, let us use them in codes below.

<!DOCTYPE html>
<html>
<body>
 <?php
  <form method=’get’>
   // rest data is here
  </form>
 ?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
 <?php
   <form method=’get’>
    // rest data is here
   </form>
 ?>
</body>
</html>
  1. First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
  2. Secondly, the <html> tag is used to indicate the beginning of an HTML document.
  3. As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
  4. Here, then we create a body tag. All the content which we want to show on browser’s screen or display is always written inside this codes.
  5. Here, as you see that we create two php forms and in first we use get method and in next we use post method. Now, the main thing is here if both are ways to submit data from forms then what the difference between them is. Let us understand.
  6. The data which we want to submit using get is showed in URL above of webpage in search bar, it means that it is not secured method if you want to login and enter your personal information and passwords somewhere.
  7. Whereas post is secured method. The data in case of post does not showed in URL.
  8. There is a limit of data in case of get method. It means that we are able to send or submit specific bytes of data whereas with help of post we are able to send unlimited data. We all know that images are string (long string). Then we are not able to send images using get method.
  9. The last thing is that we can access data from URL using get method in PHP, but this is not possible using post method. We hope that you understand difference between get and post method inside php.
  10. At last, the <body> and <html> tags are closed with </body> and </html> respectively.

Conclusion :-

At last in conclusion, here we can say that with the help of this article we are able to understand what are get and post methods and what is the difference between them.

I hope this tutorial on get and post method in PHP helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Pragati

Experienced coding content writer who enjoys breaking down complex concepts in programming languages like Java, Python, C, and C++. Over three years of experience producing interesting and relevant content for a variety of entities. Committed to providing concise and easy-to-understand articles that assist readers in easily understanding technology and industry trends in the world of coding and software development.

Follow Pragati On Linkedin 🡪