Solved

Recreating FORM "POST" without FORMS

Posted on 1997-12-03
5
162 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

864 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

24 Experts available now in Live!

Get 1:1 Help Now