SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Login Help

    Greetings,

    I am needing to write/update a javascript that, when a user logs in with invalid credentials, they get redirected to an html page. I have a cardboard cut-out script that was provided to me, but would like to adjust it for my needs. I would like to remove the "alert" portion (see below) and add *something* that will force a redirect to an error.html file located in the same directory.

    Please have a look at the portion of the script below... any help at all would be greatly appreciated.

    ----
    else if(args.statusCode == 5){
    alert("The User Name and Password combination you have entered is invalid. Please try again.");
    document.write('<img src="Alien124.gif">');
    }
    ----

    Thank you,

    JD

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mmm, javascript and login never induce a great feeling with me. But hey, as far as the answer is concerned:

    Code JavaScript:
    window.location.href = 'error.html';

    would do it. However, I'd ask to reconsider the use of javascript in any sort of login based process. For example, if the user is supposed to be redirected to another page if the login is sucessful, the person can simply view the source and copy and paste the link to the browser.

    Use cookies for authentication? Client can make their own. Anytime a client side language is used, the power is in the client, and clients can change whatever they want at that point.

  3. #3
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Chris, for your feedback. Will definitely look into other options.

    And, just to clarify, I need to replace the "alert" and "document.write" lines with the one line that you recommended?

    Thank you again,

    JD

  4. #4
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you would need to replace those lines with the one I mentioned. Also note that error.html assume that the login page and error.html are in the same directory. If not, you'll need to add the path to errror.html as well (/files/error.html for example).

    I must admit though, I'm somewhat curious as to what Alien124.gif looks like :P

  5. #5
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chris_fuel View Post
    I must admit though, I'm somewhat curious as to what Alien124.gif looks like :P
    Ask, and receive... A bit cheesy, no?

    JD
    Attached Images Attached Images


Bookmarks

Posting Permissions

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