Solved

Recreating FORM "POST" without FORMS

Posted on 1997-12-03
5
161 Views
Last Modified: 2013-12-25
I have created a search engine.  The user enters in data in the preceding form (list box and input box) and this data is passed to SEARCH2.CGI.  The engine runs through the dbase and pulls out the matches and returns it to the user.

Now the returned matches can be HUGE (400+) and so I display  a maximum of 20 matches.  A "NEXT" hyperlink text will appear for the user to click to the next page (much like YAHOO).  Now when the user clicks the NEXT text it recalls the search engine with the user data again and it will continue from where it left off and so pass back the next 20 matches.  How I achieved this is I place a LONG query string after the earch2.cgi name: (http://mysite/search2.cgi?N1=100&N2=3000&N4=1&E=100...)
The data after the "?" can be quite long.  I heard/read that the QUERY STRING size is finite (quite small) and so my enormous NEXT hyperlink probably won't work.  Is this true? What is the limit for QUERY STRING or is it server dependent?

The only thing I heard that can solve this problem is using the POST method as most of us do when we send out forms.  Problem I'm having though is how to get my NEXT hyperlink text to send its required data via the POST method withou "having" to use any form objects?

Any solutions you brainyacks?
0
Comment
Question by:mirror
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:julio011597
ID: 1831491
I guess you cannot but use a form and a bunch of hidden types to send via POST.

I'm curious as well about env vars limits: i've a couple of CGI books which don't mention anything about it, while they worry about using lots of words with an ISINDEX query.
0
 
LVL 6

Accepted Solution

by:
alamo earned 50 total points
ID: 1831492
You really shouldn't need to post the same question in both CGI and HTML, the areas are closely enough related that most experts who check one also check the other.

But since I posted a long comment over there, I might as well post it here as an answer...

Problem with using a form is you can't have a simple "Next page" link, you need a button. But still probably the easiest approach.

The safest limit is 1024 characters for the entire URL (inluding 'escaping' any non-alphanumeric characters). If your server supports 2048 characters, that's pretty safe too. Some but not all clients can handle more, so you are definitely asking for trouble over 2048 characters.

Another way to do this is to save server-side the query (in a time-stamped file), and simply refer to that in your "next" link. You need a cleanup process, though, and the page therefore isn't really bookmarkable.

Yet another approach is to use javascript to remember the search parameters page-to-page, this will work without server-side intervention as long as you know your users will have JS.

Hope this helps, good luck!
0
 

Expert Comment

by:Pozzo
ID: 1831493
well ...

the easiest way is to use a form with
<form method=post action=search2.cgi>
<input type=hidden name=N1 value=V1>
...

<input type=image src="next.gif" name="next">
</form>

as you can see on the Altavista search engine ...
using the post method of the form, data are transmitted via
the stdin/out and you are not limited to 1 ko like with Query_string (an environment variable)


0
 
LVL 6

Expert Comment

by:alamo
ID: 1831494
Well, Pozzo, actually I said that - 'But still probably the easiest approach.' You are right though, an image can be used in place of the button.

I am puzzled by your reference to AltaVista though- I use AV all the time and all I've ever seen there is normal links using GET, e.g. http://altavista.digital.com/cgi-bin/query?pg=aq&text=yes&q=whatever&stq=10
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1831495
IMO, there are a couple of reasons which make GET the best method for search engines:

first, GET makes bookmarked pages keep working;
second, you avoid the annoying "Repost form data?" dialog.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to dynamically set the form action using jQuery.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now