|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
VBScript - Database - Recordset - Why is passed in value not being matched with fields.item
Hi, I'm using access backend and I just want a form value to be matched up with a fields record on submit. My code is below...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Dim conn, sConnString Set conn = Server.CreateObject("ADODB.Connection") sConnString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("database\myDB.mdb") conn.Open(sConnString) Set rs = Server.CreateObject("ADODB.Recordset") 'rs.Open "SELECT ID FROM tblIDs ORDER BY ID", conn %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> <% 'login If Request.ServerVariables("REQUEST_METHOD") <> "POST" Then Response.Write("<p>Please Log in with provided ID Number:</p>") Response.Write("<form id=""form1"" name=""form1"" action=""Index.asp"" method=""Post"">") Response.Write("<input type=""text"" id=""IDLogin"" name=""IDLogin"" /><br />") Response.Write("<input type=""submit"" id=""loginSubmit"" name=""loginSubmit"" value=""Login"" /><br />") Response.Write("</form>") End If If Request.ServerVariables("REQUEST_METHOD") = "POST" Then rs.open "SELECT ID FROM tblIDs WHERE ID = 1", conn If rs.RecordCount > 0 Then Response.Redirect("Index1.asp?ID=" & Request.Form("IDLogin")) End If ' Do while Not rs.Eof ' if Request.Form("coachIDLogin") = rs.Fields.Item("coachID") Then ' response.Redirect("Index1.asp?ID=" & Request.Form("IDLogin")) ' End If ' rs.MoveNext 'Loop End If %> </body> </html> the bolded part above is where it's failing. The code is not going into the block where it detects if a record match is found. It just won't find a match it seems! above, I even just hardcoded a value in. And it's not detecting it. |
|
#2
|
||||
|
||||
|
I wouldn't check using request.servervariables. I'm sure one can do it that way, but I thougth sometimes the server stuff has values and sometimes it doesn't depending on where the user came from. A page that submits to itself complicates things also I think. Others will know better.
I would use the submit button. If Request.Form("loginSubmit") = "Login" Then
__________________
Fremen United! Folding@Home team ID 169647. All Fremen welcome. |
|
#3
|
|||
|
|||
|
Quote:
Hm, well that would work just to make sure they clicked login, but I want to make sure they are entering a number that will be in the db |
|
#4
|
||||
|
||||
|
Quote:
Yes, you check if they hit login. If they did you do your SQL query and authenticate them. If they didn't you show them the login form. Just what you are doing now essentially just using a different method to make the choice. |
|
#5
|
|||||||||||
|
|||||||||||
|
Mike777,
This is the unsophisticated amateur login script I use. Maybe it will help your thinking. asp Code:
Then on your pages behind the login you check to see if they are logged in asp Code:
You can then echo back on those pages with: asp Code:
HTH, BigMike Last edited by bigmike1212 : November 4th, 2009 at 11:32 PM. |
|
#6
|
||||
|
||||
|
You're welcome.
|
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > VBScript - Database - Recordset - Why is passed in value not being matched with fields.item |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|