How to do a get and post in php with restful web service server side -
Hi Anyone can retire some of the codes and how to get a cool web service and post the method. This will be server-side, so I can bring two services from the client.
Thank you! Assume that you have a script index.php, you can have two functions in it,
handleForm () . Assume that a request comes in index.php. {(Empty ($ _ server) ['REQUEST_METHOD']) {if (($ _ server ['REQUEST_METHOD']) == 'POST' on {stropper} {doSomething () ; } Else {showSomething (); }}
There you have it comfortably If you send a GET request to index.php, you will show some output, and if you send a POST request to index.php, then you will manipulate some data. You can pick from other empty HTTP request types like DELETE, etc.
Obviously this is a very simple example, and I do not want to create the entire site in this way. The best way to go about building a bad site in an architecturally sound way. Many frameworks can assist with this.
REST is just a hot topic, it seems that everyone wants their app to be cool. There are so many articles and guides on Google, you might spend some time researching different ways.
Note about URL: URI does not have to be beautiful to calm down. However, one important point of the rest is that all URIs should represent a resource. Since the query criteria are not part of any URI, " /index.php?show=2 " is not considered cool, you will find that the query parameters to rewrite multiple application URLs " / Index / 2 "like something to use.
It is being said that there is nothing wrong with "/index.php" as a URI, as long as it represents only one state.
Comments
Post a Comment