Database Driven Login Script
This script lets you to build a login script. User can login a password protected page using his/her own login username and password. All usernames and passwords stored in a MS-Access database.
</font></font><font face="courier new, courier, mono">Register Form</font><font color="#0000c0"><font face="courier new, courier, mono">
function formsubmit(myform)
{
myform.submit()
}
function checkform() {
var message = "";
if (document.newForm.uname.value.length == 0) {
message = message + "- Username field is Null.\\n\\n";
}
if (document.newForm.pword.value.length == 0) {
message = message + "- Password field is Null.\\n\\n";
}
if ( message.length > 0 ) { // is there an error message?
message = "Please, fill the form completely :\\n\\n" + message ;
alert( message ); // display error message
return false; // return bad, not ok to process
}
}
<%
if request.form("func") = "Register" then
Dim uname, pword, strCon, con, rec
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("users.mdb")
uname = trim(request.form("uname"))
pword = trim(request.form("pword"))
Set con = server.createobject("adodb.connection")
con.open strCon
set rec = con.execute("SELECT uname, pword from userlist where uname LIKE '"& uname &"' AND pword LIKE '"& pword &"';")
if NOT rec.eof then
session("loginUsername") = rec("uname")
session("loginPassword") = rec("pword")
response.write "Login was successful!"
else
response.write "Login Failed ..."
end if
rec.close
set rec = nothing
con.close
set con = nothing
end if
%>
"POST" action="login.asp" name="newForm" onsubmit="return checkform()">
"1" cellpadding="0">
"50%"> Username :
"50%"> "text" name="uname" size="15">
"50%"> Password :
"50%"> "password" name="pword" size="10">
"submit" value="Register" name="func">
Comments:
Only members can write comments.Please, login / register to write comment.

