Forum Moderators: coopster & phranque

Message Too Old, No Replies

CGI Script help required.

         

mike2

7:40 pm on Oct 13, 2004 (gmt 0)

10+ Year Member



Can anyone help with this little problem I have?

I have a website with many pages that has the following form on every page:

<form method=get action="http://wwwWebmasterWorldebsite.com/cgibin/directory/index.cgi">
<input size=40 name=search>
<input type=submit value="Search " name="submit2">
<input type=hidden name="mode" value="searchbox">
</form>

I don't want to have to change the code on every page so what I would like to do is be able to substitute the "index.cgi" file, mentioned above, for one that will re-direct and change the form information to another cgi script.

The form input for the new script looks like this:

<form method=get action="http://www.myotherwebsite.com/cgibin/differentdirectory/search.cgi">
<input type="text" name="query" size="40" maxlength="200">
<input type="submit" value="Search " name="submit">
</form>

Any ideas?

volatilegx

3:01 pm on Oct 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld mike2 :)

See [webmasterworld.com...]

The topic is closely related. What you want is to have your index.cgi send a POST request to search.cgi and then print the response.

mike2

6:11 pm on Oct 19, 2004 (gmt 0)

10+ Year Member



Manages to sort out this problem.

If anyone else is interested the code is as follows:

#!/usr/bin/perl

use CGI qw/:standard/;

my$search = param('search');
my$url = 'http://wwWebmasterWorldebsite.com/cgibin/anotherdirectory/search.cgi?query='.$search;

print header();
print qq(
<html>
<head>
<meta http-equiv="refresh" content="1;URL=$url">
</head>
<body>
If you are not forwarded <a href="$url">Click Here </a>
</body>
</html>);

exit;