PDA

View Full Version : how to workable login form with asp and databse?


designmagic
02-15-2005, 09:11 AM
hi,
i want to make simple login form.
user name (variable name:txtUsername)
password field(variable name:txtPassword)
and login button.

Button has follwoing function:

on (release,keyPress "<Enter>" )
{
if (txtUsername != "" && txtPassword != "") {
status = "Begin Login Process - Wait...";
}

{
status="";
}

submit="submit";
loadVariablesNum("flash_form.asp",0,"POST");

}

server supports asp.so, here the flash_form.asp having this script

<%@ Language=VBScript %>
<!--#INCLUDE file="inc/Connection.asp"-->
<%
dim strlocation
dim strUserName
dim strPassword
Dim strbutton

strButton = Request.form("submit")
If (strButton="submit" ) Then
strUserName = Replace(Request.Form("txtUsername"),"'","''")
strPassword = Replace(Request.Form("txtPassword"),"'","''")
UI_sql = "select * from tbllogin where username = '"&strUserName&"' and password='"&strPassword&"'"
Set UI_con = Server.CreateObject( "ADODB.Connection" )
UI_con.Open strConnectionString
Set UI_rs = UI_con.Execute(UI_sql)
If Not UI_rs.EOF Then
while Not UI_rs.EOF
strlocation = UI_rs("location")
UI_rs.MoveNext
wend
End If

UI_sql = ""
Set UI_rs = nothing
Set UI_con = nothing
if(strlocation="") Then
_root.status= "Enter the correct username and password"
Else
Response.Redirect "pageafterlogin.asp"
End if
end if

%>

can you guys tell me will it be working ? here i am using status variable as a dynamic text filed in flash form.

thanks,