login going to the current url

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

  1. #1

    Default login going to the current url

    hi

    i have a login transaction on a page, this page has url parameters passed
    through it, so when the user logs in i want he/she to be taken back to the page
    they were on( with the url parameters).
    i am using the coldfusion login system.


    i have some javascrip code which displays the current url , but i dont know
    how to incorporate this into the cf code
    below is the login page code and below it is the javascript code, i have
    starred out where the sucessful login script is.

    does anyone know how to make the login redirect the user to the current url or
    how to incorporate the javascript into the cf code?????

    any help would be appreciated
    thanks
    kamesh

    PAGE CODE
    <cfif IsDefined("FORM.textfield")>
    ************************************************** ***********
    <cfset MM_redirectLoginSuccess="admin/index.cfm">
    ************************************************** ************
    <cfset MM_redirectLoginFailed="test1.cfm">
    <cfquery name="MM_rsUser" datasource="DSNPixelwork">
    SELECT username,password FROM tbLogin WHERE username='#FORM.textfield#' AND
    password='#FORM.textfield2#'
    </cfquery>
    <cfif MM_rsUser.RecordCount NEQ 0>
    <cftry>
    <cflock scope="Session" timeout="30" type="Exclusive">
    <cfset Session.MM_Username=FORM.textfield>
    <cfset Session.MM_UserAuthorization="">
    </cflock>
    <cfif IsDefined("URL.accessdenied") AND false>
    <cfset MM_redirectLoginSuccess=URL.accessdenied>
    </cfif>
    <cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
    <cfcatch type="Lock">
    <!--- code for handling timeout of cflock --->
    </cfcatch>
    </cftry>
    </cfif>
    <cflocation url="#MM_redirectLoginFailed#" addtoken="no">
    <cfelse>
    <cfset MM_LoginAction=CGI.SCRIPT_NAME>
    <cfif CGI.QUERY_STRING NEQ "">
    <cfset MM_LoginAction=MM_LoginAction & "?" & CGI.QUERY_STRING>
    </cfif>
    </cfif>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form ACTION="<cfoutput>#MM_loginAction#</cfoutput>" name="form1"
    method="POST">
    <p> User name
    <input type="text" name="textfield">
    </p>
    <p> password
    <input type="text" name="textfield2">
    </p>
    <p>
    <input type="submit" name="Submit" value="Submit">
    </p>
    </form>
    </body>
    </html>




    JAVASCRIPT CODE
    <SCRIPT LANGUAGE="JavaScript">

    <!--
    {
    document.write(location.href);
    }
    // -->
    </SCRIPT>




    Kamesh192 Guest

  2. Similar Questions and Discussions

    1. Either BOF or EOF is True, or the current record hasbeen deleted. Requested operation requires a current record
      Can anyone pls help? I am getting the following error when search my database. "ADODB.Field (0x800A0BCD Either BOF or EOF is True, or the...
    2. Login to LDAP using current credentials
      Hello, Here is my situation. I have developed several apps that require authentication to access. For authentication, I have the users enter...
    3. Fixed Impersonation vs Current login user
      I have a ASp.NET application which performs a http request to another web site on the same server but different virtual directory. when i set...
    4. session problem - login screen continually reloads after pressing the login button
      I am trying to get sessions to work on a log in screen to give certain users access to certain pages/directories. The problem is that when the...
    5. How to change the current thread current culture at run time.
      I have created a new culture : Dim objCulture As New CultureInfo("he") //hebrew When I tried to assign it to the current thread. ...
  3. #2

    Default Re: login going to the current url

    I am assuming all this code is in one cfm file and the logic of your code goes
    like this:

    The form submit goes back to itself.
    If username and password ok , then goto index.cfm page
    else goto test1.cfm

    Are you wanting to display the login form again if it fails?


    eastinq Guest

  4. #3

    Default Re: login going to the current url

    hi

    yes the code is from one page. currently the form takes a successful login to
    the index page, but i dont want that. see below:

    there are various logins in section on my site (one on every page) if the user
    logins in successfully then i want the page they logged in from to appear. for
    example if the user logged in from [url]www.pixelwork.com/work.cfm?catID=10[/url] then i
    want the user to be taken back to [url]www.pixelwork.com/work.cfm?catID=10[/url] if the
    login was successful. if the login fails then go to test1.cfm.

    basically the site has pages where data is pulled form a database and when the
    user clicks an option a url parameter is passed through to the next page. on
    the next page a query picks up the url parameter and displays information
    accordingly.The url parameter is an ID.

    hope this makes sense to everyone!

    thanks
    kamesh

    Kamesh192 Guest

  5. #4

    Default Re: login going to the current url

    Hi

    in the CGI varaibles we have one attribute called as REFERER, this will gives
    you the name of the file by which file it has
    been referred to the login form. once the user is logins then using this
    variable you can redirect the user to the same page.

    vkunirs Guest

  6. #5

    Default Re: login going to the current url

    You should be able to go back to the referring page by using CGI.HTTP_REFERER
    eastinq 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