Skip to main content
November 9, 2006
Answered

Login Page Woes

  • November 9, 2006
  • 13 replies
  • 2033 views
I have tried over 5 tutorials.
I have read Ben Forta's CFWACK book.
I have read the followup Ben Forta Book.

After all of this. My login page will not work. Period.
Can someone PLEASE show me a code that actually WORKS?
Point me in some direction?? SOMETHING??

All I need is:

1. A login page where students enter a username and pin number.
2. they click "log in" and this magical code I have yet to find to work correctly checks the info against the DB
3. it actually WORKS and takes you to another page!! *gasps at the miracle*
4. the index page will be a list of courses in which they are enrolled.
5. the student can click on a course.
6. a class evaluation will come up specific to the course and instructor.
7. the student fills out the survey
8. presses submit
9. the survey results get bounced back to the DB in a results able where all of the answers are recorded for reporting.
10. the results should be recorded by class "index" number


does this even exist anymore?

😞
    This topic has been closed for replies.
    Correct answer Kronin555
    OK, well, now I see what's going on with your data model.

    You're storing the studentid and pin with each entry into the database. If you wanted to follow good data modeling principles, you would break that out into a Students table. Let's assume StudentID is immutable (ie, can't be changed)...

    Students
    ==========
    StudentID
    PIN
    FIRSTNAME
    MIDDLENAME
    LASTNAME

    Faculty
    ==========
    FacultyID
    FirstName
    LastName

    Course
    =========
    CourseID
    SectionNumber
    FacultyID

    StudentToCourse
    ==============
    StudentID
    CourseID

    That's if you want to do it right. If you just want to get what you have working, then you need to change the following line in LoginCheck.cfm:
    <cfif getStudent.recordCount eq 1>
    to:
    <cfif getStudent.recordCount gte 1>

    13 replies

    Participating Frequently
    November 9, 2006
    <cfquery name="getClasses" datasource="studentclasses">
    SELECT STUDENTID, COURSEID, FACULTYNAMEFIRST, FACULTYNAMELAST, INDEX, SECTIONNO, STUDENTFIRSTNAME, STUDENTMIDDLENAME, STUDENTLASTNAME
    WHERE STUDENTID = '#SESSION.auth.STUDENTID#'
    </cfquery>

    You had an extra comma after STUDENTLASTNAME.

    No, don't change the <cfset SESSION.auth.STUDENTID = getStudent.STUDENTID> in the LoginCheck.cfm. Leave that alone. Just know that you have to reference SESSION.auth.STUDENTID once a user is logged in.
    Participating Frequently
    November 9, 2006
    Once past the LoginCheck.cfm page, you shouldn't reference FORM.Username, you should reference SESSION.auth.STUDENTID.
    November 9, 2006
    hmm..
    I tried that, but it still says the same undefined error.

    Should
    <cfset SESSION.auth.STUDENTID = getStudent.STUDENTID>
    be
    <cfset SESSION.auth.USERNAME= getStudent.STUDENTID>?

    I'm trying to get

    use the STUDENTID that was used in the form and checked as being correct against the pin
    then, use that studentid to pull up all of the classes that student is enrolled in.
    Kronin555Correct answer
    Participating Frequently
    November 9, 2006
    OK, well, now I see what's going on with your data model.

    You're storing the studentid and pin with each entry into the database. If you wanted to follow good data modeling principles, you would break that out into a Students table. Let's assume StudentID is immutable (ie, can't be changed)...

    Students
    ==========
    StudentID
    PIN
    FIRSTNAME
    MIDDLENAME
    LASTNAME

    Faculty
    ==========
    FacultyID
    FirstName
    LastName

    Course
    =========
    CourseID
    SectionNumber
    FacultyID

    StudentToCourse
    ==============
    StudentID
    CourseID

    That's if you want to do it right. If you just want to get what you have working, then you need to change the following line in LoginCheck.cfm:
    <cfif getStudent.recordCount eq 1>
    to:
    <cfif getStudent.recordCount gte 1>
    November 9, 2006
    yay!

    I have finally made it past the login page!!!!
    *celebration dance*

    I have added the following code to my index page.
    It comes up with an error:
    Error Occurred While Processing Request
    Error Executing Database Query.
    Syntax error (missing operator) in query expression 'WHERE STUDENTID = '224455848''.

    The error occurred in C:\CFusionMX7\wwwroot\survey\index.cfm: line 21

    19 : <cfquery name="getClasses" datasource="studentclasses">
    20 : SELECT STUDENTID, COURSEID, FACULTYNAMEFIRST, FACULTYNAMELAST, INDEX, SECTIONNO, STUDENTFIRSTNAME, STUDENTMIDDLENAME, STUDENTLASTNAME,
    21 : WHERE STUDENTID = '#FORM.USERNAME#'
    22 : </cfquery>
    23 :



    Here's my index code:
    Participating Frequently
    November 9, 2006
    on your LoginForm.cfm page, add the following:

    <cfdump var="#FORM#">
    <cfdump var="#SESSION#">

    And add the following lines to LoginCheck.cfm, around the code I'm pasting below:

    <cflog text="In LoginCheck.cfm with username:#FORM.USERNAME#, password:#FORM.PASSWORD#, getStudent.recordcount=#getStudent.RecordCount#">
    <!---If the username and password are correct--->
    <cfif getStudent.recordCount eq 1>
    <!---Remember user's logged-in status, plus--->
    <!---SSN and StudentFirstName, in structure--->
    <cfset SESSION.auth = structNew()>
    <cfset SESSION.auth.isLoggedIn = "Yes">
    <cfset SESSION.auth.STUDENTID = getUser.STUDENTID>
    <cfset SESSION.auth.STUDENTFIRSTNAME = getUser.STUDENTFIRSTNAME>

    <cflog text="in LoginCheck.cfm: set Session variables. SESSION.auth.isLoggedIn=#SESSION.auth.isLoggedIn#">
    <!---Now that user is logged in, send them--->
    <!---to a menu of their class listings--->
    <cflocation url="CoursesMenu.cfm">
    </cfif>
    November 9, 2006
    OK, I added the 2 lines of code into the loginForm.cfm under the <body onload> tags.

    I added the code to LoginCheck....

    here's the log files:
    Date Time Severity ThreadID Application Name
    Nov 9, 2006 1:47 PM Information 0 STUDENTCOURSEEVALUATION
    I am on this page! YAY!
    Nov 9, 2006 1:47 PM Information 0 STUDENTCOURSEEVALUATION
    In LoginCheck.cfm with username:XXXXXXXXX, password:0884, getStudent.recordcount=0
    Nov 9, 2006 1:46 PM Information 0 STUDENTCOURSEEVALUATION
    I am on this page! YAY!
    Nov 9, 2006 1:46 PM Information 0 STUDENTCOURSEEVALUATION
    In LoginCheck.cfm with username:XXXXXXXXX, password:1007, getStudent.recordcount=6


    Participating Frequently
    November 9, 2006
    What are the contents of index.cfm?

    Have you closed and reopened your browser, forcing a new session, since you changed all that code?

    Did the log message in LoginCheck.cfm get output when you last posted the form?

    Did you remove the <cflocation...> from Application.cfc's onRequestStart method? What's the contents of that now?
    November 9, 2006
    What are the contents of index.cfm? The contents is below:

    <cfset path = ExpandPath("*.*")>
    <cfset directory = GetDirectoryFromPath(path)>

    <strong>You have successfully logged into the new application that the Wizard created for you</strong>
    <ul>
    <li>This application is secure, not only this file but any file that you created in the <cfoutput>#directory#</cfoutput> folder </li>
    <li>This file is the entry point for your application and can be renamed to index.cfm or anything you want, if you so desire </li>
    <li>You can also remove any or all of this text and replace it with any valid browser code that you choose, such as CFML or HTML</li>
    </ul>



    Have you closed and reopened your browser, forcing a new session, since you changed all that code? Yes, several times

    Did the log message in LoginCheck.cfm get output when you last posted the form?
    Nov 9, 2006 1:14 PM Information 0 STUDENTCOURSEEVALUATION
    I am on this page! YAY!



    Did you remove the <cflocation...> from Application.cfc's onRequestStart method? What's the contents of that now?
    <!---
    Filename: Application.cfc
    Author: Chelsie Lawson (cml7u@uvawise.edu)
    Please note that this file executes for every page request.
    --->
    <cfcomponent output="false">
    <!---Name the Appliation.--->
    <cfset this.name="StudentCourseEvaluation">
    <!---Turn on session management.--->
    <cfset this.sessionManagement="true">
    <cffunction name="onApplicationStart" output="false" returntype="void">
    <!---Any variables set here can be used by all of our pages--->
    <cfset APPLICATION.datasource = "studentclasses">
    <cfset APPLICATION.companyname = "Student Course Evaluation">
    </cffunction>
    <cffunction name="onRequestStart" output="false" returntype="void">
    <!---If user isn't logged in, force them to now--->
    <cfif not isDefined("SESSION.auth.isLoggedIn")>
    <!---If the user is now submitting login form,--->
    <!---Include "Login Check" code to validate user--->
    <cfif isDefined("FORM.USERNAME")>
    <cfinclude template="loginCheck.cfm">
    </cfif>
    <cfinclude template="loginForm.cfm">
    <cfabort>
    </cfif>
    </cffunction>
    </cfcomponent>

    Participating Frequently
    November 9, 2006
    Are you sure you saved the changes to LoginForm.cfm? In the code sample you posted, it's posting to index1.cfm.

    If you're absolutely positive, did you do a shift-reload of the login form? That will force your browser to ignore its cache and re-request the page from the server.
    November 9, 2006
    Just to double check, I saved the login form again, did a shift+refresh.
    When I did the refresh, I had a website error come up in the status bar. (I don't know the official name, but it's when you have a yellow trianle in the bottom left of your browser window) I opened it up and it said a value I had on the page was null. I searched the page for it and found out that my <body onload> cursor placement tag was calling the wrong field (because I had renamed the userLogin to USERNAME and the LoginForm to just simply FORM. So, I changed that and the error did not appear again.


    Now, when I enter my username and pin and click login, jsut like before, the page seems to refresh, yet, in the address bar it reflects the: http://127.0.0.1:8500/survey/index.cfm.but, it just shows the login box like I haven't logged in at all....


    I will paste my loginForm.cfm code:


    Participating Frequently
    November 9, 2006
    OK.

    Take this out of Application.cfc:
    <cflocation url="CoursesMenu.cfm">

    Take this out of LoginForm.cfm:
    <!---If the suer is now submitting "Login" form,--->
    <!---Include "Login Chelsie" code to validate user--->
    <cfif isDefined("FORM.UserLogin")>
    <cfinclude template="LoginCheck.cfm">
    </cfif>

    Upon successful login in LoginCheck.cfm, they are redirected to CoursesMenu.cfm. If that's not where you want to send them, change it in that page (LoginCheck.cfm), and only that page.

    No worries about the frustration, I just wanted you to know that you were making it difficult to help you. We'll get this working, let's just take it one step at a time.
    November 9, 2006
    I deleted both sections.
    In LoginCheck.cfm......the cflocation url is pointing to the CoursesMenu.cfm, which I assume is why the page was ending up there.

    so, now it looks like this:
    <cflocation url="index.cfm">

    And then, on the loginFOrm.cfm, the form action looks like this:
    <cfform action="index.cfm" name="FORM" method="post">

    However, I am now getting an error saying that index.cfm is not found. But, I did a search for index1 in my code for each page and no results...so, how is it calling something that's not even there?

    Here's the error:

    Error Occurred While Processing Request
    File not found: /survey/index1.cfm


    Please try the following:
    Check the ColdFusion documentation to verify that you are using the correct syntax.
    Search the Knowledge Base to find a solution to your problem.


    Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)
    Remote Address 127.0.0.1
    Referrer http://127.0.0.1:8500/survey/loginForm.cfm
    Date/Time 09-Nov-06 12:42 PM

    Stack Trace (click to expand)



    coldfusion.runtime.TemplateNotFoundException: File not found: /survey/index1.cfm
    at coldfusion.filter.PathFilter.invoke(PathFilter.java:83)
    at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
    at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:50)
    at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
    at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
    at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
    at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
    at coldfusion.CfmServlet.service(CfmServlet.java:105)
    at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
    at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
    at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
    at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
    at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
    at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:349)
    at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:457)
    at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:295)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)






    Participating Frequently
    November 9, 2006
    cml7u,

    Pause. Take a deep breath.

    I have no idea what your code is doing, because you've changed it. I don't know where your form is posting, nor what the path of execution is through your files. Stop changing stuff for 5 minutes, post what you have, and let me take a look at it. I need you to not change anything after you post it until I respond, otherwise my responses might not be applicable. This is getting frustrating on my end as I'm trying to help you.
    November 9, 2006
    Here's my code.
    I'm sorry I'm frustrating you :(
    Participating Frequently
    November 9, 2006
    OK, wait...

    "when I click login, the login screen refreshes, BUT the address bar reads : http://127.0.0.1:8500/survey/CoursesMenu2.cfm
    that file is empty....I need it to go to index....how can I get that to happen?"

    So you click Login. The form posts, and you receive the login form again? (that's what I get from "the login screen refreshes", but even though you see the login screen, the URL is:
    http://127.0.0.1:8500/survey/CoursesMenu2.cfm
    ?
    What do you mean by "that file is empty"? The page you receive is empty when you view source? or /survey/CoursesMenu2.cfm is empty?

    You need to go to index. Index.cfm? index.cfm in /survey/?

    What code are you actually running now, as you've been changing it up. Where is the log statement you put in that got written to application.log?

    Again, let's take things one step at a time. Don't get flustered and trash what you have so far and start over. Continue to work on one codebase until we get this working.
    Participating Frequently
    November 9, 2006
    Where to check it... in the coldfusion administrator, under "Log Files", in the application.log by default.

    Where to put it... wherever you want to find out if your program is getting there or not, or wherever you want to output some variable to see what the value of that variable is at that point. Debug lines, basically, except being written to a log file rather than output to the browser.

    For example, put the following line at the top of a .cfm page:

    <cflog text="I am on this page! YAY!">

    Now run that page and go look at the application.log file.
    November 9, 2006
    I think we're making progress! Somewhat.

    I placed the cflog tag in my LoginCheck.cfm.

    after my login attempt, I actually received the:
    Nov 9, 2006 11:18 AM Information 0 STUDENTCOURSEEVALUATION
    I am on this page! YAY!


    which is a HUGE success/...? maybe?


    but, when I click login,
    the login screen refreshes, BUT, the address bar reads: http://127.0.0.1:8500/survey/CoursesMenu2.cfm

    that file is empty....I need it to go to index....how can I get that to happen?
    November 9, 2006
    OK, so I found the spot where I needed to change that. (it was in my form action)
    now I get the error:




    Error Occurred While Processing Request
    Element USERNAME is undefined in FORM.


    The error occurred in C:\CFusionMX7\wwwroot\survey\LoginCheck.cfm: line 20

    18 : SELECT STUDENTID, STUDENTFIRSTNAME
    19 : FROM StudentClasses
    20 : WHERE STUDENTID = '#FORM.USERNAME#'
    21 : AND PIN = '#FORM.PASSWORD#'</cfquery>
    22 :



    --------------------------------------------------------------------------------

    Please try the following:
    Check the ColdFusion documentation to verify that you are using the correct syntax.
    Search the Knowledge Base to find a solution to your problem.


    Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)
    Remote Address 127.0.0.1
    Referrer http://127.0.0.1:8500/survey/loginForm.cfm
    Date/Time 09-Nov-06 11:27 AM

    Stack Trace (click to expand)
    at cfLoginCheck2ecfm796882873.runPage(C:\CFusionMX7\wwwroot\survey\LoginCheck.cfm:20) at cfApplication2ecfc1527089435$funcONREQUESTSTART.runFunction(C:\CFusionMX7\wwwroot\survey\Application.cfc:22)


    coldfusion.runtime.UndefinedElementException: Element USERNAME is undefined in FORM.
    at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1054)
    at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1031)
    at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1130)
    at cfLoginCheck2ecfm796882873.runPage(C:\CFusionMX7\wwwroot\survey\LoginCheck.cfm:20)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
    at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:343)
    at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1908)
    at cfApplication2ecfc1527089435$funcONREQUESTSTART.runFunction(C:\CFusionMX7\wwwroot\survey\Application.cfc:22)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:348)
    at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:294)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:258)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:56)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:211)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:173)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:192)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:145)
    at coldfusion.runtime.AppEventInvoker.invoke(AppEventInvoker.java:55)
    at coldfusion.runtime.AppEventInvoker.onRequestStart(AppEventInvoker.java:97)
    at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:195)
    at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
    at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
    at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:50)
    at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
    at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
    at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
    at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
    at coldfusion.CfmServlet.service(CfmServlet.java:105)
    at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
    at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
    at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
    at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
    at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
    at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:349)
    at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:457)
    at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:295)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)