Hi, Im trying to create a simple login page but i cant seem to figure out whats the problem with my code. It redirects user if he enters the wrong username/ password combo but if it is correct it doesnt take user to welcome.cfm ... Please help
Here it is :
LOGIN PAGE
<FORM NAME="CFForm_1" ACTION="login_action.cfm" METHOD=POST onSubmit="return _CF_checkCFForm_1(this)">
login:<br>
<INPUT TYPE="text" NAME="username"><br>
<input type="hidden" name="username_required" value="You must enter your User Name">
Password:<br>
<INPUT TYPE="password" NAME="password"><br>
<input type="hidden" name="password_required" value="You must enter your Password">
<center>
<input type="SUBMIT" value="Login" name="login">
</center><br>
</FORM>
********************
LOGIN_ACTION PAGE
<cfif NOT IsDefined ('form.username')>
<cflocation url="login.cfm" addtoken="No">
</cfif>
<cfquery name="gilwayb" datasource="AuthorizedUsers">
SELECT *
FROM Users
WHERE USERNAME = '#FORM.username#'
AND PASSWORD = '#FORM.password#'
</cfquery>
<CFSET Session.LoggedIn = "1">
<CFSET Session.FName = "#gilwayb.fName#">
<CFIF gilwayb.RecordCount IS 0>
<cflocation url="login.cfm" addtoken="No">
<CFSET StructClear(Session)>
<cfelse>
<CFSET Session.LoggedIn = "1">
<cflocation url="welcome.cfm" addtoken="No">
</cfif>
*****************
WELCOME PAGE
<CFIF NOT IsDefined("Session.LoggedIn"
>
<CFSET StructClear(Session)>
<CFLOCATION URL="login.cfm">
</CFIF>
<H1><CENTER>WELCOME <cfoutput>#session.FIRSTNAME#</cfoutput> !</H1></CENTER>
Here it is :
LOGIN PAGE
<FORM NAME="CFForm_1" ACTION="login_action.cfm" METHOD=POST onSubmit="return _CF_checkCFForm_1(this)">
login:<br>
<INPUT TYPE="text" NAME="username"><br>
<input type="hidden" name="username_required" value="You must enter your User Name">
Password:<br>
<INPUT TYPE="password" NAME="password"><br>
<input type="hidden" name="password_required" value="You must enter your Password">
<center>
<input type="SUBMIT" value="Login" name="login">
</center><br>
</FORM>
********************
LOGIN_ACTION PAGE
<cfif NOT IsDefined ('form.username')>
<cflocation url="login.cfm" addtoken="No">
</cfif>
<cfquery name="gilwayb" datasource="AuthorizedUsers">
SELECT *
FROM Users
WHERE USERNAME = '#FORM.username#'
AND PASSWORD = '#FORM.password#'
</cfquery>
<CFSET Session.LoggedIn = "1">
<CFSET Session.FName = "#gilwayb.fName#">
<CFIF gilwayb.RecordCount IS 0>
<cflocation url="login.cfm" addtoken="No">
<CFSET StructClear(Session)>
<cfelse>
<CFSET Session.LoggedIn = "1">
<cflocation url="welcome.cfm" addtoken="No">
</cfif>
*****************
WELCOME PAGE
<CFIF NOT IsDefined("Session.LoggedIn"
<CFSET StructClear(Session)>
<CFLOCATION URL="login.cfm">
</CFIF>
<H1><CENTER>WELCOME <cfoutput>#session.FIRSTNAME#</cfoutput> !</H1></CENTER>