Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LOG IN PAGE - CODE CHECK PLEASE

Status
Not open for further replies.

kingjjx

Programmer
Sep 18, 2001
181
US
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=&quot;CFForm_1&quot; ACTION=&quot;login_action.cfm&quot; METHOD=POST onSubmit=&quot;return _CF_checkCFForm_1(this)&quot;>

login:<br>
<INPUT TYPE=&quot;text&quot; NAME=&quot;username&quot;><br>
<input type=&quot;hidden&quot; name=&quot;username_required&quot; value=&quot;You must enter your User Name&quot;>
Password:<br>
<INPUT TYPE=&quot;password&quot; NAME=&quot;password&quot;><br>
<input type=&quot;hidden&quot; name=&quot;password_required&quot; value=&quot;You must enter your Password&quot;>

<center>
<input type=&quot;SUBMIT&quot; value=&quot;Login&quot; name=&quot;login&quot;>
</center><br>

</FORM>

********************

LOGIN_ACTION PAGE

<cfif NOT IsDefined ('form.username')>
<cflocation url=&quot;login.cfm&quot; addtoken=&quot;No&quot;>
</cfif>

<cfquery name=&quot;gilwayb&quot; datasource=&quot;AuthorizedUsers&quot;>
SELECT *
FROM Users
WHERE USERNAME = '#FORM.username#'
AND PASSWORD = '#FORM.password#'
</cfquery>

<CFSET Session.LoggedIn = &quot;1&quot;>
<CFSET Session.FName = &quot;#gilwayb.fName#&quot;>

<CFIF gilwayb.RecordCount IS 0>
<cflocation url=&quot;login.cfm&quot; addtoken=&quot;No&quot;>
<CFSET StructClear(Session)>
<cfelse>
<CFSET Session.LoggedIn = &quot;1&quot;>
<cflocation url=&quot;welcome.cfm&quot; addtoken=&quot;No&quot;>
</cfif>


*****************
WELCOME PAGE

<CFIF NOT IsDefined(&quot;Session.LoggedIn&quot;)>
<CFSET StructClear(Session)>
<CFLOCATION URL=&quot;login.cfm&quot;>
</CFIF>


<H1><CENTER>WELCOME <cfoutput>#session.FIRSTNAME#</cfoutput> !</H1></CENTER>


 
Change your login action page to:

<cfif NOT IsDefined ('form.username')>
would normally redirect
</cfif>

<cfquery name=&quot;gilwayb&quot; datasource=&quot;AuthorizedUsers&quot; debug>
SELECT *
FROM Users
WHERE USERNAME = '#FORM.username#'
AND PASSWORD = '#FORM.password#'
</cfquery>

<CFSET Session.LoggedIn = &quot;1&quot;>
<CFSET Session.FName = &quot;#gilwayb.fName#&quot;>

<CFIF gilwayb.RecordCount NEQ 1>
not logged in
<cfelse>
logged in
</cfif>

this modification leaves all your options intact... it just tells you what the script is trying to do.. And will output useful query information at the bottom of the page...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top