Forum Moderators: open
<%
variable1 = Request.form("Search")
%>
<!--#include file="connection.inc"-->
<%
DIM mySQL, objRS
mySQL = "INSERT INTO SiteSearch (Search) VALUES ('" & variable1 & "');"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn
%>
<form method="POST" action="searchtest2.asp">
<p>
<input type="text" name="Search" size="20">
<input type="submit" value="Submit" name="">
</p>
</form>
Your search for <%=Request("Search")%>
That is what you are looking for.
Without all your details, there is no sense writing out some code for you to cut and paste into your file.
You have all the tools you need, you just need to learn the syntax for doing what you want to do.
Research that syntax and your problem will be solved.
So how do you determine 'Flow of events'? Well just walk it through on a white board or piece of paper. I've even done em on restaurant napkins during lunch.
Here's an idea to get you going:
--> User arrives on search page.
--> Is Search Submitted?
--> Yes
--> Isolate IP Address (Research Request.ServerVariables to accomplish this step)
--> Isolate Search Phrase (Research Request.Form to accomplish this step)
--> Record Search Phrase (Looks like you have that but logistically it's in the wrong place)
--> Perform Search Algorithm
--> Do Results exist?
--> No
--> Gracefully inform the user.
--> Yes
--> Unwind result set.
--> No
--> Do nothing.
Now, once you've done this. Think up some ways to break it (illegal characters for example). This is testing and it's really important if your application is going to interact with a database. Testing might reveal bugs in your algorithm that you'll want to correct before writing any code.
After you feel that you've got the bugs all ironed out then write your code. You'll be much better off in the long run by hammering out all of your bugs while your in design. That way when you sit down to write your code it's going to go very fast and with very little re-writes.
<!--#include file="connectstring.inc"-->
<%
DIM mySQL, objRS
mySQL = "INSERT INTO SiteSearch (Search, Time, Date, IPaddress) VALUES ('" & variable1 & "','" & Time() & "','" & Date() & "','" & variable2 & "');"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn
%>
I am self taught, so appologise in advance. This now works and sends info to db and passes the string accross to the results part.....pat myself on the back Clap, clap.
The results part just for the moment is made up of a simple frontpage wizard which will be changing shortly.
The bit that i am not sure on is:
--> Isolate IP Address (Research Request.ServerVariables to accomplish this step) --> Isolate Search Phrase (Research Request.Form to accomplish this step)
Also how do i go about counting results?
Im not doing bad for a beginer though!
The bit that i am not sure on is: (Research Request.Form to accomplish this step)
--> Isolate IP Address (Research Request.ServerVariables to accomplish this step)
sUsersIPAddress = Request.ServerVariables("REMOTE_ADDR")
Also how do i go about counting results?
Like so:
variable1 = Request.form("Search")
If Trim(variable1) <> "" Then
Rem - ok to save the phrase
mySQL = "INSERT INTO SiteSearch (Search) VALUES ('" & variable1 & "');"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn
End If
You'll find Trim() under String Functions. Bone up on asp a bit then get started.