Home > ASP Development > Code problem? or what?

Code problem? or what?



hi to all... i got big prob. here... i can't trap my log in... seems this i have this and i dont know whats wrong with it... every time i put any name on my textbox.. my login.asp page goes to home.asp without trapping.. plz help.. below are my codes...

thnx!


Code:



<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%response.buffer = true%>
<%
Session("DatabasePath") = "C:\Inetpub\wwwroot\thesis\dbase\userdb.mdb"
If Request.Form("btnLogin") = "Login" AND Request.Form("username") <> "" _
AND Request.Form("Password") <> "" Then

'-- Declare your variables
Dim DataConnection, cmdDC, RecordSet
Dim username, password

username = Request.Form("username")
password = Request.Form("password")

'-- Create object and open database
Set DataConnection = Server.CreateObject("ADODB.Connection")
DataConnection.Open "FILEDSN=C:\Inetpub\wwwroot\thesis\dbase\connect.ds n;" & _
"DBQ=" & Session("C:\Inetpub\wwwroot\thesis\dbase\userdb.mdb") & ";"

Set cmdDC = Server.CreateObject("ADODB.Command")
cmdDC.ActiveConnection = DataConnection
....
'-- default SQL
SQL = "SELECT * FROM user_table"

If Request.Form("username") <> "" Then
SQL = "SELECT user_table.* FROM user_table " & _
"WHERE user_table.username='" & username& _
"' AND user_table.password ='" & password & "'"
End If

cmdDC.CommandText = SQL
Set RecordSet = Server.CreateObject("ADODB.Recordset")






--owell

    
Guest


Two things. First, since the code you provided is VBScript, you should change

Code:


<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>


to

Code:


<%@ Language = "VBScript" %>






Second, my guess is your form is not posting to this code. There is nothing in this code that would send you back to your home.asp page. Double check how your form tag is setup and where it posts too. Second, in case there is more code you did not provide, try adding in a few response.write statements and see what your form is posting.



Hope this helps.



- Ol髍in

Was this answer helpful ? Yes No   
Guest


hello and welcome to aspfree, owell!



first, when you next post code please use the code tags.

second, your code have some basic errors... for example change this:


Code:


DataConnection.Open "FILEDSN=C:\Inetpub\wwwroot\thesis\dbase\connect.ds    n;" & _
"DBQ=" & Session("C:\Inetpub\wwwroot\thesis\dbase\userdb.mdb") & ";"




to this:


Code:


DataConnection.Open "FILEDSN = C:\Inetpub\wwwroot\thesis\dbase\connect.dsn;" &_
"DBQ=" & Session("DatabasePath") & ";"




as for your current problem, you have to debug your code as Ol髍in said:


Code:



Response.Write("button value: "&Request.Form("btnLogin")&"<br />")
Response.Write("login: "&Request.Form("username")&"<br />")
Response.Write("password: "&Request.Form("Password")&"<br />")
Response.END




let us know the results, probably one of those is empty or not what you expecting.

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved