Hej. Har du rätt namn på filerna? jodå.. allt är rätt.. originalen är lite annorlunda än den jag postade, jag gjorde om lite eftersom det blev lättare att förklara. ledsen för det, glömde ändra överallt i koden. försök ignorera mitt misstag. Du kan ju prova:Login medlem till access db - Check problem
Jag har en form där man fyller i sitt namn + pwd. sedan skickas detta till en check_member.asp sida som kollar databasen om namn & pwd finns. Finns dessa, skall sidan göra redirect till member.page1.asp (just nu, i denna kod, skriver den ut namnet, om det finns).
(Databasen ligger på brinkster.com, så anvisning till db är korrekt.)
När jag kör det, får jag ingen felmeddelande av brinkster, utan det kommer bara upp "This page cannot be displayed.. etc..."
Vad är fel i min kod?
Form.asp:
<code>
<html>
<head><title>Login </title> </head>
<body bgcolor="#666699" text="white">
<div align="center"><br><br><br><br>
<form action = "check_member.asp" method="post">
<table>
<tr>
<td align="left">Användarnamn: </td>
<td><input type="text" name="anv"></td>
</tr>
<tr>
<td align="left">Lösenord:</td>
<td><input type="password" name="pwd"></td>
</tr>
</table>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</p>
</form>
</div>
</body>
</html>
</code>
Och nu check.asp:
<code>
<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit
Dim oConn
Dim sSql
Dim name
Dim passwrd
Dim oRs
Dim check
%>
<html>
<body>
<%
check=0
anv=Request.Form("anv")
pwd=Request.Form("pwd")
'----DB conn---
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\n2002n\db\login.mdb"))
sSQL = "SELECT name, passwrd FROM login WHERE passwrd='"& pwd &"'AND name='"& anv &"'"
Set oRS = oConn.Execute(sSQL)
Do While NOT oRS.EOF
check=1
'Response.Redirect "member_page1.asp"
Response.Write("<br><h3><center>Välkommen<br> " & oRS("name").Value & "</center></h3>")
oRS.MoveNext
Loop
'----end DB check
'----If user not in db
If check=0 Then
Response.Redirect "login_form_error.asp"
End If
'---close conn
oConn.Close
Set oRS = Nothing
Set oConn = Nothing
%>
</body>
</html>
</code>
Tacksam för all hjälp som Ni kan ge mig.
/Erik I.
ICQ#419799Sv: Login medlem till access db - Check problem
I din första fil sätter du action till: "check_member.asp"
Och nedanför visar du kod för "check.asp"
Tryckfelsnisse, eller?Sv: Login medlem till access db - Check problem
jag har försökt få igång denna kod i evigheter, har testat olika typer för att få den att funka.
En annnan kod-typ jag försökte, som inte heller funka, var denna:
check.asp (check_member.asp);
<code>
<%
Dim anv
Dim pwd
Dim db
Dim rs
'Response.Write("<font size=2 face=arial>")
'Response.Write("Checkar om du e medlem eller ej...<br>")
Set db = Server.CreateObject("ADODB.Connection")
db.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath ("login.mdb")
anv = Request.Form("anv")
pwd = Request.Form("pwd")
SQL = "SELECT anv, pwd FROM Login WHERE (anv='" & anv & "','" & pwd & "')"
'Set rs = db.Execute(SQL)
Response.Write SQL
If rs("anv") = "" Or rs("pwd") = "" Then
Response.Write "FEEEEL!"
Else
Session("anv") = anv
Session("pwd") = pwd
Response.Redirect "member_page1.asp"
End If
%>
</code>Sv: Login medlem till access db - Check problem
<code>
<%@ LANGUAGE="VBSCRIPT" %>
<html>
<body>
<% Option Explicit
Dim sSql
Dim name
Dim passwrd
Dim oRs
Dim oConn
anv=Request.Form("anv")
pwd=Request.Form("pwd")
'----DB conn---
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\n2002n\db\login.mdb")
sSQL = "SELECT name, passwrd FROM login WHERE passwrd='"& Replace(pwd,"'","''") &"'AND name='"& Replace(anv,"'","''") &"'"
Set oRS = oConn.Execute(sSQL)
If oRS.EOF Then
Response.Write "<br><h3><center>Välkommen<br> " & oRS("name").Value & "</center></h3>"
Else
Response.Redirect "login_form_error.asp"
End If
oRS.Close
Set oRS = Nothing
oConn.Close
Set oConn = Nothing
%>
</body>
</html>
</code>