Click to See Complete Forum and Search --> : Making an AOL-type keyword system
bruce66
04-12-2003, 12:10 PM
I would like to set up a search system with the following features:
1) If the user inputs some keywords contained in my hardcoded list (i.e. "email," "documents," etc.) they will be forwarded to respective pages.
2) If the keywords are not contained on the system, the user (and keyword) will be forwarded to some search engine.
Anyone heard of this script existing?
Thanks!
Yup, it can be done. Something like this:
<html><head>
<script>
function a3(){
if(document.formName.textName.value=="document"){location="document.html";}else if(document.formName.textName.value=="index"){location="/index.html";}else if(document.formName.textName.value=="email"){location="email.html";}else { location="http://google.com?hl=en&ie=UTF-8&oe=UTF-8&q="+document.formName.textName.value+"&btnG=Google+Search";}
}
</script></head>
<body>
<form name="formName">
<input type=text name="textName"><br>
<input type=button value="Go!" onClick="a3();">
</form></body></html>
bruce66
04-13-2003, 01:00 PM
Thanks for your help.
One last question:How can I get the results to appear in a new (or specified) window?
Nevermore
04-13-2003, 01:08 PM
Change the location= to windowName.location=
jamiers
10-13-2003, 06:16 AM
Does anyone know of a perl or php script that could be used in place of the javascript? I maintain a school web site and would like the keyword box on the main page to call a script and then get redirected...
Does anyone know of anything? I have been searching many sites and haven't seen anything....
HELP for a so-so techie operating a school's web site. Teacher by trade -- not a programmer :confused:
Thanks!
Jamie
<?php
if($_SERVER["HTTP_REQUEST"] == "GET"){
if($_GET["name_of_search_field_in_form"] == "document") Header("location:document.html");
if($_GET["name_of_search_field_in_form"] == "index) Header("location:index.html");
} else { // if method of form is POST
if($_POST["name_of_search_field_in_form"] == "document") Header("location:document.html");
if($_POST["name_of_search_field_in_form"] == "index") Header("location:index.html");
}
?>
Keep in mind that the Location header function will only work if you call it before data is sent to the browser.
[J]ona
Nevermore
10-13-2003, 11:40 AM
I would recommend using GET not POST so that the page can be bookmarked.
Originally posted by cijori
I would recommend using GET not POST so that the page can be bookmarked.
Yes, good point.
[J]ona
There is a quote error in line 4 around index:
if($_GET["name_of_search_field_in_form"] == "index) Header("location:index.html");
Also, the funciton Header should be written in lowercase, as header (http://us2.php.net/manual/en/function.header.php)