Solved

Should I use post or get to go to a specific record in a list of records

Posted on 2016-10-08
3
65 Views
Last Modified: 2016-10-08
I have just set up a contact form that both stores the data in a database as well as emails me data from the submitted form. If I go to my dashboard area I can see a list of messages received. My first thought would be to use a get request to view each one e.g.:

<a href="contact_detail.php?contact_id=<?php echo $contact_id; ?>">

Open in new window


I just noticed though that experts exchange does not have something like this if I check my list of questions and click on one. Instead I see something like:

https://www.experts-exchange.com/questions/123456/name-of-question.html

Does it look like that because they are performing url rewriting to get pretty urls or are they using post instead of get?

And that makes me wonder, should I use post or get for what I am doing? I thought GET was the normal way of doing it.
0
Comment
Question by:Black Sulfur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41835077
They are using GET - as those are simple links - POST only works with a form or AJAX request - you can't post with <a>

In EE's case they are either using URL rewriting or slugs that in the database map to the question.

In terms of pretty url's these make sense on public sites where you want Search engines to see your pages and people to remember URL's (not that anyone does that). On a site that has a dashboard - implies a login which makes URL rewriting unnecessary. You can still do it - but in my view - a whole bunch of effort for no payoff.

I would go with a plain old URL with parameters.

If down the line you decide you want to use a different format say
contact/1/25
You an still do this with URL rewriting without having to change your internal structure.
0
 
LVL 1

Author Comment

by:Black Sulfur
ID: 41835079
Okay, good explanation. Thanks!

I want to ask a related question to this so will open up a new question.
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41835115
You are welcome.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question