Login error with CFIF statement

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Login error with CFIF statement

    Hi all: I'm having trouble with a login CFIF routine. The following code
    works fine when the login is TRUE, but when I try to login with invalid info
    the CFELSE statement doesn't kick in and I end up with a blank action page
    screen, rather than being redirected back to the login screen. I can't figure
    out why the CFELSE is not kicking in...

    ....<CFELSEIF action EQ "login">

    <CFQUERY NAME="qry_Login" DATASOURCE="#Database.DSN#">
    SELECT Username, Password
    FROM tblUsers
    WHERE Username = '#Form.Username#' AND Password = '#Form.Password#'
    </CFQUERY>

    <CFOUTPUT QUERY="qry_Login">
    <CFIF qry_Login.Recordcount EQ 1>

    <CFSET Client.LoggedIn = "True">
    <CFSET Client.UserName = '#Username#'>

    <CFLOCATION URL="index.cfm?action=viewposts" ADDTOKEN="No">

    <CFELSE>
    <CFLOCATION URL="index.cfm?action=login" ADDTOKEN="No">
    </CFIF>

    </CFOUTPUT>

    <CFELSEIF>....


    n | d | a Guest

  2. Similar Questions and Discussions

    1. Repeating output with cfif statement
      I have a problem when multiple checkboxes are "turned on' when multiple values exist for a field in a database. For example: The following code...
    2. Help with cfif statement
      Can anyone help me find the correct way to write the following statement? <cfif form.user2 NEQ 15 or 50 or 51 or 52 or 53 or 55 or 200 or 223 or...
    3. CFIF Statement problems
      I am trying to write a cfif statement, which shows a form only if the statemnt acts true. It is a 3 part statement, the first two parts appear to...
    4. Using cfoutput within a cfif statement
      I am trying to setup a form validation, what i need to do is look at the Specimen Number entered and compare it against the database to see if it...
    5. LOGIN: ERROR- Failed to initialize policy manager. (IFOR_PM_FATAL) Login sessions denied.
      Verify that you haven't set the system date by mistake to a far away future. All the licenses then become expired! Restoring the system to the...
  3. #2

    Default Re: Login error with CFIF statement

    Is this your login check form?
    The Dagger Guest

  4. #3

    Default Re: Login error with CFIF statement

    Maybe try:
    <cfelse>
    <cfinclude template="nameofloginform.cfm">
    </cfif>
    The Dagger Guest

  5. #4

    Default Re: Login error with CFIF statement

    You're doing this:

    <CFOUTPUT QUERY="qry_Login">
    <CFIF qry_Login.Recordcount EQ 1>

    <CFSET Client.LoggedIn = "True">
    <CFSET Client.UserName = '#Username#'>

    <CFLOCATION URL="index.cfm?action=viewposts" ADDTOKEN="No">

    <CFELSE>
    <CFLOCATION URL="index.cfm?action=login" ADDTOKEN="No">
    </CFIF>

    </CFOUTPUT>

    Note that you have a cfoutput of the query in question over the whole cfif
    test. If there aren't any records returned in that query, the cfoutput won't be
    processed (because the query doesn't have any records).

    Change it to:

    <CFIF qry_Login.Recordcount EQ 1>

    <CFSET Client.LoggedIn = "True">
    <CFSET Client.UserName = '#qry_Login.Username#'>

    <CFLOCATION URL="index.cfm?action=viewposts" ADDTOKEN="No">

    <CFELSE>
    <CFLOCATION URL="index.cfm?action=login" ADDTOKEN="No">
    </CFIF>

    Note that the <cfoutput query="qry_Login">, </cfoutput> is completely gone.

    Kronin555 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139