Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Whats wrong with this Script?  (Read 3400 times)

0 Members and 1 Guest are viewing this topic.

Bannana97

    Topic Starter


    Intermediate
  • Owner of HerbertsWorld Corporation
    Whats wrong with this Script?
    « on: January 19, 2009, 02:41:31 PM »
    It keeps saying invalid login even when i enter the correct info.






    <html>
    <head>
    <title>Login</title>
    <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=="Bannana97" && password=="se5asokn1") { window.location="userbailey451497529.html"; done=1; }
    if (username=="micky" && password=="bailey") { window.location="usermicky00000191.html"; done=1; }
    if (username=="apple202" && password=="passlolword") { window.location="userapple202ifsdhgio.html"; done=1; }
    if (done==0) { alert("Invalid login!"); }
    }
    // End -->
    </SCRIPT>
    </head>
    <body>
    <script link="http://www.herbertsworld.com/scriptholder.html" >
    </script>
    <center>
    <form name=login>
    <table width=225 border=1 cellpadding=3>
    <tr><td colspan=2><center><font size="+2">Login: Account</font></center></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>
    </body>
    </html>
    Thanks
    Bannana97

    kpac

    • Web moderator
    • Moderator


    • Hacker

    • kpac®
    • Thanked: 184
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 7
    Re: Whats wrong with this Script?
    « Reply #1 on: January 19, 2009, 02:46:10 PM »
    <script link="http://www.herbertsworld.com/scriptholder.html" >
    </script>

    You are missing a type attribute and "link" should be "src". It should be:

    <script src="http://www.herbertsworld.com/scriptholder.html">
    </script>


    I'm not sure if that will work as it is a HTML file...

    Bannana97

      Topic Starter


      Intermediate
    • Owner of HerbertsWorld Corporation
      Re: Whats wrong with this Script?
      « Reply #2 on: January 19, 2009, 03:37:23 PM »
      No that isnt the problem, It works for all my other pages.

      The login keeps saying Login Incorrect even with the correct info.
      Thanks
      Bannana97

      EchoLdrWolf316



        Intermediate

      • Don't worry, Javascript is just Flash on speeeeed.
        Re: Whats wrong with this Script?
        « Reply #3 on: January 19, 2009, 07:51:21 PM »
        I'd say the problem is that your running the  'if (done==0) { alert("Invalid login!"); }'  script on the same level as 'var done=0;' so it's immediately activating. I'm not good with javascript, but a tabbed
        Code: [Select]
        else if () command might work.

        kpac

        • Web moderator
        • Moderator


        • Hacker

        • kpac®
        • Thanked: 184
          • Yes
          • Yes
          • Yes
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 7
        Re: Whats wrong with this Script?
        « Reply #4 on: January 20, 2009, 02:15:32 AM »
        I'd say the problem is that your running the  'if (done==0) { alert("Invalid login!"); }'  script on the same level as 'var done=0;' so it's immediately activating. I'm not good with javascript, but a tabbed
        Code: [Select]
        else if () command might work.

        Yes, this could be the problem.

        <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=="Bannana97" && password=="se5asokn1") { window.location="userbailey451497529.html"; done=1; }
        elseif (username=="micky" && password=="bailey") { window.location="usermicky00000191.html"; done=1; }
        elseif (username=="apple202" && password=="passlolword") { window.location="userapple202ifsdhgio.html"; done=1; }
        else  { done==0; alert("Invalid login!"); }
        }
        // End -->
        </SCRIPT>


        You might also have a problem with the username and password variables. To me, you are defining the same variables twice.

        var username=document.login.username.value;
        username=username.toLowerCase();
        var password=document.login.password.value;
        password=password.toLowerCase();


        Might be something like this:

        var user=document.login.username.value;
        username=user.toLowerCase();
        var pass=document.login.password.value;
        password=pass.toLowerCase();

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: Whats wrong with this Script?
        « Reply #5 on: January 20, 2009, 03:04:28 AM »
        No that isnt the problem, It works for all my other pages.

        The login keeps saying Login Incorrect even with the correct info.

        yeah, it's not a problem that your using attributes that don't exist.  ::)
        I was trying to dereference Null Pointers before it was cool.