Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:52:22+00:00 2026-06-14T06:52:22+00:00

I’m working on my first web application and have this basic doubt. I have

  • 0

I’m working on my first web application and have this basic doubt.

I have a group of posts and I want to allow users to vote on them. I’m working with PHP so I have an article.php script with code that handle HTTP requests.

At the moment I implemented article creation which uses data sent through a POST HTTP request (using html form). The article id returned is the one I get from the DB storing articles.

Similarly, I handle GET requests and return an article based on the id sent as a parameter. If no parameter is defined, I return a list of all articles.

For the moment I haven’t done any url rewrite so requests are of the form article.php?id=xxx

Now I want to implement votes, and this is where I’m facing a problem. According to REST, I should use POST on a specific resource (given that votes aren’t idempotent) so I’d send a POST request to /article/1234 with a body "+1" for a positive vote.

The question is, how do I map the above to my use case? Assuming url rewrite was made, what would that translate to? Doing a rewrite to article.php?id=1234 wouldn’t work because POST doesn’t take parameters in the URI (AFAIK).

And also, how would I distinguish this action from any other? Should I also add some “action” parameter like article.php?id=1234&action=vote?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:52:23+00:00Added an answer on June 14, 2026 at 6:52 am

    It seems as did not get the real idea of a REST-ful application. Retrieving the articles with GET and edit it with POST is fine, but you have to expand this to votes. REST-ful applications assume that one url identifies one resource. So, you have to think of votes as an own resource (that are related to articles).
    So, your application should work like this

    GET article.php/id/1: retrieve the article with id 1

    POST article.php/id/1: alter the artcile with id 1

    GET article.php/id/1/votes: retrieve the votes of the article with id 1

    POST article.php/id/1/votes: alter the votes of article with id 1

    Its completely fine to implement the latter one with adding one up-vote, as long as votes are implemented as a simple counter.
    You may redefine this logic by giving the votes identity, e.g. if you want to add more attributes to a vote like the user who made the vote.

    As you asked for the rewrite and if an application is able to get data from the url with a post-request: Yes, thats completely possible. A POST request to article?id=1 will have $_GET[‘id’] available.

    The rewrite-part as shown above is completely optional. REST is not interested in the “niceliness” of a url as long as ONE url identifies ONE resource.

    Hopefully this gave you an idea of how to continue

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.