Click to See Complete Forum and Search --> : How to make a login form call the database results for login form


guythatsnotsure
04-17-2006, 03:43 PM
Hi, I would like a nice little code to call a database fields that are named username and password. All i need is a function. The db name is register. I have a register form that sends the results to a file with the database. Heres just the text fields and button i have done.

username: <input type="text" name="username" width="20" style="border-style: outset">

password: <input type="password" name="password" width="20" style="border-style: outset">

<input type="submit" name="login" value="login" style="font-family: Verdana; color: #233966; font-size: 11px; font-weight: bold; background-color: #FFFFFF;">

Ok, well thx. :)

ProWeb
04-19-2006, 12:32 PM
All depends on which database your using and how you wish to connect to it.
Ive made a few assumuptions such as your posting the form and you wish to check the username and password to allow access to a particular page.

SQLStmt = "Select password from register where username = '"& request.form("username")&"'"
Set RS = MyConn.Execute(SQLStmt)
If RS.EOF Then
Response.Write("Invalid Username")
LoggedIn = False
Else
If Request.form("Password") = RS("Password") then
LoggedIn = True
Else
Response.Write("Incorrect Password, Commencing Destruction Sequence!")
LoggedIn = False
end if
end if

Its quick and dirty but will work. Theres also lots of scripts on the net that are really easy to use that are much more secure.

Good Luck