ChapterÂ 2.Â HTTP Verbs
HTTP verbs such as
POST let us send our intention along with the URL so we can instruct the server what to do with it. Web requests are more than just a series of addresses, and verbs contribute to the rich fabric of the journey.
POST because itâs very likely youâre already familiar with those. There are many verbs that can be used with HTTPâin fact, we can even invent our ownâbut weâll get to that later in the chapter (see Using Other HTTP Verbs). First, letâs revisit
POST in some detail, looking at when to use each one and what the differences are between them.
Making GET Requests
URLs used with
GET can be bookmarked, they can be called as many times as needed, and the request should not affect change to the data it accesses. A great example of using a
GET request when filling in a web form is when using a search form, which should always use
GET. Searches can be repeated safely, and the URLs can be shared.
Consider the simple web form in FigureÂ 2-1, which allows users to state which category of results theyâd like and how many results to show. The code for displaying the form and the (placeholder) search results on the page could be something like this:
/>Rows per ...
Get PHP Web Services now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.