Gossamer Forum
Home : Products : Links 2.0 : Customization :

Which Way Search Box

Quote Reply
Which Way Search Box
I'm wanting to set up my search box to where there are option buttons. If one option is selected, the search term is searched at my site with the links2 search engine. If the other option box is selected, the keyword is copied and send to another site. Here is how I tried to set it up:

#######The Actual Form:

<form method=POST action="http://www.activewebmaster.com/cgi-bin/searchit/searchit.cgi">
<input size=25 name="key">
<input type=submit value="Search!">

<input type="radio" name="where" value="ActiveWebmaster" checked>ActiveWebmaster

<input type="radio" name="where" value="TheWeb">The Web</p>
</form>

################################

#######Here is the script I made the form points to:
(sorry, not too good at writing perl yet)


#!/usr/local/bin/perl

if ($FORM{'where'} eq 'ActiveWebmaster') {
$search = $form{'key'};
print "Location: http://www.activewebmaster.com/cgi-bin/links/search?query=$search\&mh=25\&type=keyword\&bool=and\n\n";
}

else {
$search = $form{'key'};
print "Location: http://www.bid4search.com/cgi-bin/smartsearch/bid4search.cgi?keywords=$search\n\n";
}

###########################End Script

For some reason, when I enter a word into the form, it always takes me to bid4search.com but doesn't put the keyword in.

Could someone please help me fix the form and/or script?

Best Wishes,
Eric J. Griffin

http://www.ActiveWebmaster.com - Webmaster Resources Cool
Quote Reply
Re: Which Way Search Box In reply to
Hi Eric:

You haven't parsed the form input so $FORM is undefined. Check out: http://www.perl.com/...al/html/lib/CGI.html


Dan Cool

LotusLand
Vancouver, BC, Canada
Top Ranked City in World for Quality of Life
Quote Reply
Re: Which Way Search Box In reply to
Use CGI qw(:standard);

Then instead of $FORM{'where'}; either use param('where'); or create a new CGI object...

my $IN = new CGI;

$where = $IN->param('where');

Then you don't need to parse the form.

Installs:http://www.wiredon.net/gt/
MODS:http://wiredon.net/gt/download.shtml

Quote Reply
Re: Which Way Search Box In reply to
I tried using the method PaulWilson suggested, and now I get an internal server error. Could someone please tell me what I'm doing wrong. Keep in mind I know Very minimal sytax rules for PERL. Here is what the script(searchit.cgi) reads:

#!/usr/local/bin/perl

$key = new CGI;
my $IN = new CGI;
$where = $IN->param('where');

if ($where eq 'ActiveWebmaster') {
print "Location: http://www.activewebmaster.com/cgi-bin/links/search?query=$key\&mh=25\&type=keyword\&bool=and\n\n";
}

else {
print "Location: http://www.bid4search.com/cgi-bin/smartsearch/bid4search.cgi?keywords=$key\n\n";
}

######################End Script

Once again, this is the form that calls the script:

<form method=POST action="http://www.activewebmaster.com/cgi-bin/searchit/searchit.cgi">
<input size=25 name="key">
<input type=submit value="Search!">
<input type="radio" name="where" value="ActiveWebmaster" checked>ActiveWebmaster
<input type="radio" name="where" value="TheWeb">The Web</p>
</form>


Do I have to do the same thing I did to get $where to get $key working or what?

Thanks again,
Eric J. Griffin

http://www.ActiveWebmaster.com - Webmaster Resources Cool
Quote Reply
Re: Which Way Search Box In reply to
1) You need to use search.cgi and then escape the ? in the query string.

2) If that doesn't work, then check the syntax of the file:

Code:

perl -c search.cgi


Regards,

Eliot Lee
Quote Reply
Re: Which Way Search Box In reply to
you didn't follow Paul's suggestion correctly...

a) you don't have 'use CGI' anywhere
b) you have two CGI objects
c) if you use CGI, you should use redirect()
d) read the documentation: perldoc CGI
Code:
#!/usr/local/bin/perl -w
use CGI qw(:standard);
my ($where, $query) = (param('where'), param('query'));
if ($where eq 'ActiveWebmaster') {
redirect("http://www.activewebmaster.com/cgi-bin/links/search?query=$query\&mh=25\&type=keyword\&bool=and");
} else {
redirect("http://www.bid4search.com/cgi-bin/smartsearch/bid4search.cgi?keywords=$query");
}
--Drew
Free, hot camel soup for Links hackers...
http://www.camelsoup.com