LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-13-2013, 02:54 PM   #1
stateless
Member
 
Registered: Jan 2013
Distribution: Debian
Posts: 151

Rep: Reputation: 4
html: submitting form data as GET parameters instead of POST?


Hi. I'm no expert at HTML, but I'm forced to become one because of a django project I have been assigned. I have a page which has a search box, which sends string data to a page over POST. However, it would simplify some other code if the form would send the data as GET parameters. (The search does not change the server/data, so this makes philosophical sense as well.) Is there some setting you change in the form HTML to make it do that, or do you have to use some kind of advanced Javascript? I know some search engine search boxes do this, but I'm not sure exactly how.
 
Old 02-13-2013, 04:14 PM   #2
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Crunchbang, Debian
Posts: 315

Rep: Reputation: 77
Hi. Just changeing the value of the method attribute from post to get should do the trick.

Code:
<form action="whatever" method="get">
 
2 members found this post helpful.
Old 02-14-2013, 08:18 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by joe_2000 View Post
Hi. Just changeing the value of the method attribute from post to get should do the trick.

Code:
<form action="whatever" method="get">
This might work if the accordant code on the server is agile enough to determine what method was used. Don't know about Django, but the code that services the form may be hardwired to use one particular method. If you are replacing that code anyway, it won't really matter. The nature of the form often dictates the most appropriate method to use. Post requests may be more appropriate for larger volumes of data.

--- rod.
 
Old 02-14-2013, 06:03 PM   #4
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,268

Rep: Reputation: 1086Reputation: 1086Reputation: 1086Reputation: 1086Reputation: 1086Reputation: 1086Reputation: 1086Reputation: 1086
Generally speaking, POST is by-far more flexible in what sort of data it can easily transfer. You probably don't want to change it to use GET. Django is perfectly capable of handling data that arrives in either format .. in fact, it should not care. Figure out what you do not yet understand about Django, and do not (please do not take me wrongly here ...) "screw things up" because you don't yet.

You're barking up the wrong tree .. and about to make a big mistake. Learn more about Django. Don't do anything yet.
 
Old 02-14-2013, 10:39 PM   #5
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,570

Rep: Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394
Sundiavlvcs, what does he not understand about Django, and what big mistake is he about to make?

Last edited by dugan; 02-15-2013 at 11:21 AM.
 
Old 02-15-2013, 01:08 PM   #6
stateless
Member
 
Registered: Jan 2013
Distribution: Debian
Posts: 151

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by sundialsvcs View Post
Generally speaking, POST is by-far more flexible in what sort of data it can easily transfer. You probably don't want to change it to use GET. Django is perfectly capable of handling data that arrives in either format .. in fact, it should not care. Figure out what you do not yet understand about Django, and do not (please do not take me wrongly here ...) "screw things up" because you don't yet.

You're barking up the wrong tree .. and about to make a big mistake. Learn more about Django. Don't do anything yet.
Situation is basically this: I have a page that provides searches of data through a form, and the same page displays search results. Currently, the form sends search requests information over post. However, some search results, and sometimes even other pages, have hyperlinks which send in additional search information (i.e., new searches) through GET parameters in the hyperlink. So, in the backend, there has to be /both/ code for handling search request information received over POST and search request information received over GET.

So, naturally I wanted to simplify the code, by unifying this to one method or the other. GET makes more sense to me, because 1) I don't know how to have a hyperlink send parameters over POST, and 2) the searches do not change the database, and 3) if search request info is sent over GET, then search results can be "saved" through bookmarks. Now, if somebody has a better argument or a better approach, my ears are open.
 
Old 02-15-2013, 01:13 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
sundialsvcs makes a good point. Please tell us how you expect anything to become simpler by changing the HTTP request method. Your use of the phrase 'which sends string data to a page over POST' makes me wonder how strong your understanding of HTTP is (since it is technically somewhat nonsensical; and I'm not trying to disparage you). It does sound like you may be trying to address a problem, or perceived problem from the wrong angle.

--- rod.
 
Old 02-15-2013, 01:17 PM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by stateless View Post
in the backend, there has to be /both/ code for handling search request information received over POST and search request information received over GET.
Any well crafted website should work this way, IMHO. It is the agility I referred to in a prior post.
--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] HTML POST form gets 403 with certain characters in input Snark1994 Programming 4 05-30-2012 11:35 AM
capture html form data blizunt7 Programming 12 06-19-2005 08:31 PM
Submitting a POST Form with Links HappyDude Programming 0 10-24-2004 02:07 AM
HTML, PHP, forms, submitting data Problem Silent1 Programming 3 08-31-2004 03:03 PM
PHP and HTML Form Post Savahn Programming 12 06-30-2004 03:15 PM


All times are GMT -5. The time now is 12:15 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration