How to place a Name in a index page after login page

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default How to place a Name in a index page after login page

    Hello everyone. I just started to learning ColdFusion and I was wondering when
    someone registers and they place their first and last name and e-mail and
    password and so forth. Then they are brought to a login page and are asked to
    place their username and password. Once logged in, in the index page or main
    page I wanted to have something stand out and say Good morning or good
    afternoon with their first name. How do I do that. I've been trying over and
    over but I can't get it to function. I also have made an Application.cfm with
    the login information. Can someone help me where someone enters a site after
    when they have placed their e-mail and password that in the main menu they
    first name shows up and welcomes them? Here is my code for login_form.cfm,
    index.cfm and application. Thank you, AdonaiEchad
    ---------------------------------------

    login_form.cfm
    ------------------
    <cfinclude template="semheader.cfm"/>
    <div id="divTitle">Seminary Students Login</div>
    <div id="divContent">
    <div id="divLoginTable4">
    <div class="logintext">Not <a
    href="/lomm/seminary/register/user_register.cfm">register?</a></div>

    <cfform action="/lomm/seminary/index.cfm" method="post">
    <table width="200" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="qDetails">Username:</td>
    <td><cfinput type="text" name="email" class="field" required="yes"
    message="You must enter your username as your e-mail address." /></td>
    </tr>
    <tr>
    <td class="qDetails">Password:</td>
    <td><cfinput type="password" name="password" class="field" required="yes"
    message="You must enter your password." /></td>
    </tr>
    <tr>
    <td colspan="2">
    <cfinput type="image" name="login_button"
    src="/lomm/images/buttons/login_btn.gif" class="login_btn" />

    </td>
    </tr>
    </table><br><br>

    <div class="logintext">Want to go back to LOMM website <a
    href="/lomm/index.cfm">Click Here</a></div>
    </div>
    </div>
    </cfform>

    <cfinclude template="semfooter.cfm"/>

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



    index.cfm
    -------------
    <cfinclude template="semheader.cfm"/>
    <div id="divTitle">Welcome to LOMM Seminary</div>
    <div id="divContent">

    <br>
    <img src="../images/contentimages/logo9.jpg" name="seminarylogog"
    width="350" height="272" class="seminarylogo" id="eminarylogo">
    <br>

    </div>
    <cfinclude template="semfooter.cfm"/>
    </div>


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


    Application.cfm
    --------------------

    <cfset sLOMM = "lommseminary" />

    <cflogin>
    <cfif isDefined ('FORM.login_button.y')>
    <cfquery datasource="#sLOMM#" name="qLogin">
    SELECT users.user_id, user_type.type
    FROM users, user_type
    WHERE user_type.user_type_id = users.user_type_id
    AND users.email = '#FORM.email#'
    AND users.password = '#FORM.password#'
    </cfquery>
    <cfif qLogin.RecordCount GT 0>
    <cfloginuser name="#qLogin.user_id#" password="#FORM.password#"
    roles="#qLogin.type#"/>
    <cfelse>
    <cfset sHeaderMessage = "The e-mail and password combination you tried is
    incorrect." />
    <cfinclude template="login_form.cfm" />
    <cfabort />
    </cfif>
    <cfelse>
    <cfinclude template="login_form.cfm" />
    <cfabort />
    </cfif>
    </cflogin>

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

    AdonaiEchad Guest

  2. Similar Questions and Discussions

    1. Trouble loading administrator/index.cfm page--i am askedto save the page
      Please help....i've been stuck for days on this problem... Basically, I installed coldfusion and at the end of the installation, it told me that...
    2. making a login page which shud lead to a https page ?
      (Type your message here) making a login page which shud lead to a https page ? ne suggestions -------------------------------- From: sneha...
    3. my user login page is always the default page
      :brokenheart; my coldfusion application has an login page, some users logged in and saved some page to favorites, then close the browser without...
    4. index page vs home page
      When I publish my web pages (Publisher 2002) to the hosting site and then access them, it always opens to a file listing rather than to the home...
  3. #2

    Default Re: How to place a Name in a index page after loginpage

    In your CFIF code to determine if they are a valid user or not, you need to set
    their name if successful. So after you log them in, put <cfset
    session.firstnamefield = #qlogin.firstnamefield#>. Once you do that you can
    simply pull up their name from anywhere in your app just by typing
    #session.firstnamefield#.

    pflynn02 Guest

  4. #3

    Default Re: How to place a Name in a index page after loginpage

    I am a bit confused, where do I place the <cfset session.firstnamefield =
    #qlogin.firstnamefield#> which I assume will be in the Application.cfm file.
    This is where I placed <cfset session.firstnamefield = #qlogin.firstnamefield#>
    as <cfset session.name_first = #qlogin.name_first#> <!---New Code---> , in the
    Application.cfm, is this correct? ------------------------------ <cfset sLOMM =
    'lommseminary' /> <cflogin> <cfif isDefined ('FORM.login_button.y')>
    <cfset session.name_first = #qlogin.name_first#> <!---New Code---> <cfquery
    datasource='#sLOMM#' name='qLogin'> SELECT users.user_id, user_type.type
    FROM users, user_type WHERE user_type.user_type_id = users.user_type_id
    AND users.email = '#FORM.email#' AND users.password = '#FORM.password#'
    </cfquery> <cfif qLogin.RecordCount GT 0> <cfloginuser
    name='#qLogin.user_id#' password='#FORM.password#' roles='#qLogin.type#'/>
    <cfelse> <cfset sHeaderMessage = 'The e-mail and password combination you
    tried is incorrect.' /> <cfinclude template='login_form.cfm' /> <cfabort
    /> </cfif> <cfelse> <cfinclude template='login_form.cfm' /> <cfabort />
    </cfif> </cflogin> ----------------------------- For the
    #session.firstnamefield# I placed it as #session.name_first#, is this correct?
    ----------------- <cfinclude template='semheader.cfm'/> <div
    id='divTitle'>Welcome to LOMM Seminary</div> <div id='divContent'> <cfoutput>
    <!---New Code---> #session.name_first# <!---New Code---> </cfoutput> <!---New
    Code---> <br> <img src='../images/contentimages/logo9.jpg'
    name='seminarylogog' width='350' height='272' class='seminarylogo'
    id='eminarylogo'> <br> </div> <cfinclude template='semfooter.cfm'/>
    </div> When I tried this I am getting an error that says... ----- Error
    Occurred While Processing Request Element NAME_FIRST is undefined in QLOGIN.
    The error occurred in
    C:\CFusionMX7\wwwroot\lomm\seminary\Application.cf m: line 7 5 : 6 : <cfif
    isDefined ('FORM.login_button.y')> 7 : <cfset session.name_first =
    #qlogin.name_first#> <!---New Code---> 8 : <cfquery datasource='#sLOMM#'
    name='qLogin'> 9 : SELECT users.user_id, user_type.type
    --------------------------- What am I missing? Thank you, AdonaiEchad

    AdonaiEchad Guest

  5. #4

    Default Re: How to place a Name in a index page after loginpage

    You placed it wrong, it goes after this line of your application file: <cfset
    session.name_first = #qlogin.name_first#> <cfloginuser name='#qLogin.user_id#'
    password='#FORM.password#' roles='#qLogin.type#'/> Also, in your query you
    need select the name_first field.

    pflynn02 Guest

  6. #5

    Default Re: How to place a Name in a index page after loginpage

    Thank you so much, you've been most helpful. I really appreciate your patience with me on this.
    AdonaiEchad Guest

  7. #6

    Default Re: How to place a Name in a index page after loginpage

    No problem!
    pflynn02 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