Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with logging in script please

    I'm looking for the right javascript that will help me with a log in and password ... scripty thing. I've set up my forms, username and password, and my Log In button. My passwords and usernames are stored in the script. What I need now is that when they are accepted, all the pages of my website are updated with the words, "welcome *username*" somewhere on the page. That's all I'd like to happen. Nothing like editing profiles and their own page or stuff like that; this is just for a small project. Just a welcome *username* message.

    This is the script i am using. I just don't know what else I need to put in to make this work. Am i using the wrong script for what I want to happen? I have a feeling that the destination pages are wrong for what i want to happen... I am really not good at javascript at all unfortunately!

    Help WOULD be appreciated! I need this in the next two days!

    SCRIPT LANGUAGE="JavaScript">



    <!-- Begin
    function Login(){
    var done=0;
    var username=document.login.username.value;
    username=username.toLowerCase();
    var password=document.login.password.value;
    password=password.toLowerCase();
    if (username=="member1" && password=="password1") {
    window.location="index.html"; done=1; }
    if (username=="member2" && password=="password2") {
    window.location="index.html"; done=1; }
    if (username=="member3" && password=="password3") {
    window.location="index.html"; done=1; }
    if (done==0) { alert("Invalid login!"); }
    }
    // End -->


    Insert into <BODY>
    <center>
    </h1>
    <form name=login>
    <table width=225 border=1 cellpadding=3>
    <tr><td colspan=2>
    <p align="center"><font size="+2"><b>Log in!</b></font></p>
    </td></tr>
    <tr><td>Username:</td><td><input type=text name=username></td></tr>
    <tr><td>Password:</td><td><input type=password name=password></td></tr>
    <tr><td colspan=2 align=center><input type=button value="Login!" onClick="Login()"></td></tr>
    </table>
    </form>
    </center>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,734
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    If you had used the search facility you would have found that the same question had been asked and answered already this week alone.

    If all you want is "Welcome UserName" then you should store UserName in a cookie on the client computer. Anything else really requires server side programming. But see also

    Secure Login with javascript

    which is probably secure enough for your purposes. I take it that you realise that storing the user names and passwords within the script is very insecure indeed and easily circumvented by anyone who knows even a smattering of JavaScript.

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm sorry Philip M if I have wasted your time, but thank you very much for your help.

    Yes I realise the insecurity of storing passwords in the script, which is why I am only going to use this as a trial until my scripting skills increase.

    Once again i apologise.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,734
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    No need to grovel - but please do use the search feature in future as a starting point.

    This explains how to set and read a cookie containing username:-

    http://webmonkey.wired.com/webmonkey...tw=programming

  • #5
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ah! thankyou very much!

  • #6
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can this be done without using a testing server? If so, how do I go about it? I apologise - my knowledge of cookies and javascript is minimum.


  •  

    Posting Permissions

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