View Full Version : Creating Dreamweaver MX 2004 Log In Page
Guest0014
January 3rd, 2004, 02:08 PM
I'm using Dreamweaver's MX 2004 new feature creating log in page. I do everything like it was described in help. I even did an online tutorial which is also described everything I was doing.
I enter same values as in database under User and Password fields, but instead of opening "success" page it keeps opening "fail" page no matter what I enter. What can be wrong?:h:I'm out of ideas. Please help.:)
bsw2112
January 5th, 2004, 10:50 AM
can you post some code?
what language are you using?
bsw
bsw2112
January 5th, 2004, 11:04 AM
here is a sample code using ASP
<%
dim objConn, objRS, SQL, coStr
SET objConn = SERVER.CreateObject("ADODB.Connection")
SET objRS = SERVER.CreateObject("ADODB.Recordset")
coStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
coStr = coStr & "DBQ=" & Server.MapPath("..\db\ecom.mdb") & ";"
objConn.Open(coStr)
sql = "SELECT * from customer where customer.lastname='" & Request.Form("lastname") & "' and customer.password='" & Request.Form("userpassword") & "'"
Set objRS = objConn.Execute(sql)
if objRS.EOF = true Then
Response.write("No such user in our system. Please try again <a href='login.html'>Back</a>")
else
Response.write("<H4>Welcome back " & objRS("firstname") & "</h4>")
end if
%>
the code establishes a connection to a database (access in this case)
dim objConn, objRS, SQL, coStr
SET objConn = SERVER.CreateObject("ADODB.Connection")
SET objRS = SERVER.CreateObject("ADODB.Recordset")
coStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
coStr = coStr & "DBQ=" & Server.MapPath("..\db\ecom.mdb") & ";"
objConn.Open(coStr)
***********************************************
and opens a table called customer
and queries it for a particular last name and password
sql = "SELECT * from customer where customer.lastname='" & Request.Form("lastname") & "' and customer.password='" & Request.Form("userpassword") & "'"
Set objRS = objConn.Execute(sql)
it compares it to variables that were sent from a form on another page called login.html
on that form fields were called lastname and userpassword
*******************************************
if there is a match (the record set is not at end of file (objRS.EOF)
the welcome message is shown with proper user options
if there is no match, objRS.EOF = true
a warnimg message is shown "please try again etc.. and a link to the login page is displayed
if objRS.EOF = true Then
Response.write("No such user in our system. Please try again <a href='login.html'>Back</a>")
else
Response.write("<H4>Welcome back " & objRS("firstname") & "</h4>")
' more code would go here to give user options
end if
*******************************************
hope this helps a little
this is just one way of doing what you want
cheers
bsw
mindfriction
January 12th, 2004, 01:34 AM
Hey,
Just thought I should add, you have to be careful to the way you implement the MS Access DB in ASP as it is possible for a hacker to exploit your code and essentially download your entire DB ! That is, if they know the URL of your mdb....you're in trouble...
Yes chances of that are limited, but if for some reason there is an error in connecting to your db or an error in an include file a user may easily obtain the URL if the db lay in wwwroot. Just make sure put your mdb file in a higher directory so the client cant access it
:red:
Guest0014
January 13th, 2004, 01:28 PM
I'm using Coldfusion MX.
<cfif IsDefined("FORM.UserName")>
<cfset MM_redirectLoginSuccess="../new_news_update.cfm">
<cfset MM_redirectLoginFailed="fail.cfm">
<cfquery name="MM_rsUser" datasource="accessbase">
SELECT UserName,Password,AccessLavel FROM tblLogin WHERE UserName='#FORM.UserName#' AND Password='#FORM.Password#'
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.UserName>
<cfset Session.MM_UserAuthorization=MM_rsUser.AccessLavel[1]>
</cflock>
<cfif IsDefined("URL.accessdenied") AND false>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock"><!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
</cfif>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
I'm using Microsoft Access.
Guest0014
January 13th, 2004, 01:52 PM
All was created through log in wizard. I didn't change a thing.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.