Get And Post Method In PHP
Last Updated : Jan 1, 2023
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>
- First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
- Secondly, the <html> tag is used to indicate the beginning of an HTML document.
- 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.
- 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.
- 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.
- 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.
- Whereas post is secured method. The data in case of post does not showed in URL.
- 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.
- 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.
- At last, the <body> and <html> tags are closed with </body> and </html> respectively.
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.