|
Free printable Sudoku Puzzles | Custom Word Search Puzzles | iptocountry.info | Free web storage |
| Add a search utility to your site |
|
This search utility will allow you to search for terms or phrases within your site, and the resulting page will show your visitors the title of the page and a link to it. You only need to include the form bellow in your page:
|
| searchfiles.html |
|
<form method="POST" action="/cgi-bin/searchfiles.asp">
<table border=0 cellpadding=5 bgcolor=AAAAAA><tr> <td align=center> Search term or phrase <input type=text name=term size=15> <input type=submit value="search"></td> </tr></table> </form> |
|
And you will need to create a file with the content in the table bellow
named searchfiles.asp in the corresponding
directory. Active Server Pages must be available in the server.
You may copy the script bellow from a text
file. Instructions are in the bottom.
|
| searchfiles.asp |
|
<%
SearchTerm = request.form("term") Novalid=" a b c d e f g h i j k l m n o
p q r s t u v w x y z yes no and more"
if instr(SearchTerm,Novalid)=0 then Response. Write ("<CENTER><H2>Search results</H2></CENTER>")
FolderName= "FolderName"
else
SearchResponse=""
<%
Wfile = f1.name
if instr(ct2,SearchTerm2)>0 then
if instr(ct,"</title>")>0 then
SearchResponse= SearchResponse +"<TR><TD>"+ ct + "</TD><TD
ALIGN=CENTER VALIGN=MIDDLE>" + " <A HREF=" + "/" + FolderName + "/"
+ Wfile +"> More </A></TD></TR>"
end if
Next Response.Write ("<HTML><HEAD><TITLE>Search results</TITLE></HEAD><BODY BGCOLOR=FFFFFF><CENTER>") Response.Write ("<TABLE BORDER=0 WIDTH=550><TR><TD BGCOLOR=C0C0C0><FONT SIZE=5><B>Search Results</B></FONT></TD></TR></TABLE>") Response.Write ("<TABLE BORDER=0 WIDTH=550>")
Response.Write ("<TABLE BORDER=0 WIDTH=550><TR><TD BGCOLOR=C0C0C0 ALIGN=RIGHT><FONT SIZE=1>Search utility provided by <A HREF=http://www.asptutorial.info>AspTutorial.info</A></FONT></TD></TR></TABLE>") Response.Write ("</CENTER></BODY></HTML>") End Sub
|
|
You may include the terms you do not want to be searched in the variable "Novalid". In case a term included in "Novalid" is request, write your response in the variable "NovalidResponse". "Search results" is the text which will be shown in the top of the search results page. "FolderName" is the directory you want to search. Only ".htm" and ".html" files in this directory will be searched. Subdirectories are not search. In case you want to search your top directory, set FolderName="". This script is only useful in top directories only. I do not recommend to check more than 50 files (Try to be friendly with your server!) "AspTutorial.info" is my site. Please, do not remove the link to my site. Thanks This script will show as a response a list of the titles of pages
with the requested term of phrase.
|
2006@ AspTutorial.info. All rights reserved.