Dear all,

They told me that this forum teaches Perl in a friendly atmosphere, so I
hope you can help me. My name is Henk van Ess and I run www.voelspriet.nl, a
Dutch site about searchengines (non-commercial).

I'm busy with a form for searching all kind of special operators in search
engines and I want to do that job with radioboxes.

One radiobox should give the following output:

http://www.google.com/search?q(FIXED VALUE)+(VARIABLE)

where FIXED VALUE= allintitle: and the VARIABLE is the search term that the
user enters.

EXAMPLE:

Say someone searches for the word Perl and checks the radiobox "Search title
only", I will need the output:

http://www.google.com/search?q=allintitle%3A+perl

EXTRA INFO:

The form/script I want to make is intended to reduce typing. If someone
searches for the title of the
webpageon Google normally, he will have to enter:

allintitle: (search term)

With the form/script the user will have to check the radiobox "Search title
only", type the search term and voila, there's the answer.

WHAT I DID TILL NOW:

As you see I will have to use the name="q" for input twice. I think I've got
some wonderfull advice, but I can't bake a cake of the snippets people have
sent me. It feels that I'm so close.

Here is the HTML I started with:

<!-- Search Google -->
<center>
<FORM method=GET action="http://www.google.nl/search"; target="_blank">
<TABLE bgcolor="#FFFFFF"><tr><td>
<INPUT TYPE=text name=q size=25 maxlength=255 value="">
<INPUT type=submit name=btnG VALUE="Search">
&nbsp;<br>
<input type="radio" name="????" value="allintitle:">Search a title of a
webpage only<br>
</td></tr></TABLE>
</FORM>
</center>
<!-- Search Google -->


THIS IS THE ANSWER I'VE GOT:

(cut)

You are attempting to drive the Google search
directly from your form, with no intervening CGI script of your own. In that
case, you are limited to the variable names and values understood by the
Google script and have no capability to combine values as needed to compose
the URL you want.

With your own CGI script, it's fairly simple. Assume you've named that ????
button as "prefix".

$host="www.google.nl";
$q = param('q');
$prefix = param('prefix');
$q = $prefix . "%3A+" . $q;
...
... deal with num, nl, and so on
...
$url = "http://$host?q=$q&num=$num...";;
print "Location: $url\n\n"; # redirect

so you've just reformatted the variables sent from the user's form into the
URL needed to drive the Google search. (The use of the param() function is
common to several CGI libraries...you may have to use something slightly
different, depending on which library you chose to use -- you definitely
want to use a CGI library rather than rolling your own from scratch.)

Prefix might not be checked. In that case, you'd not want to do the line

$q = $prefix . "%3A+" . $q;

so change that to be:

$q = $prefix . "%3A+" . $q if $prefix;

(cut)

BACK TO MY QUESTION
------------------------------

Can someone spell it out for me what I have to put in the HTML-code and what
exactly in the .cgi or .pl??

What do i put in the HTML to get the CGI running? SO what do I put here:

<input type="radio" name="????" value="allintitle:">Search a title of a
webpage only

to link the HTML to the CGI?

And how does the CGI look? How do I start and end that script? Can you write
it out for me?

I will credit you on my site for helping me... so be prepared to get famous
:)

Henk van Ess
www.voelspriet.nl


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to