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 7 of 7

Thread: Login Page.

  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Login Page.

    I made a forum and I need help with the login page. I have This so far
    Code:
    <?
    require('config.php');
    ?>
    
    <?php include('header.php'); ?>
    
    <h2>User Login</h2>
    
    <form method="post" action="logon_user.php">
    
    <table>
    <tr><td>Username:</td><td><input name="username" type="text" /></td></tr>
    <tr><td>Password:</td><td><input name="password" type="password" /></td></tr>
    </table>
    
    <input type="submit" name="Submit" value="Submit" class="button"/> <input type="reset" name="Submit2" value="Reset" class="button"/>
    
    
    
    </form>
    
    
    <?php include('footer.php'); ?>
    Im trying to add a javascript code to verify that the user name and password has been entered...Can someone help me with this? Im not sure what the code would be or where to put it...All help would be appreciated.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,080
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    <form name = "myform" method="post" action="logon_user.php" onsubmit = "return validate(this.Submitbutton)">

    <table>
    <tr><td>Username:</td><td><input name="username" type="text" /></td></tr>
    <tr><td>Password:</td><td><input name="password" type="password" /></td></tr>
    </table>

    <input type="submit" name="Submitbutton" value="Submit" class="button" /> <input type="reset" name="Submit2" value="Reset" class="button"/>

    <SCRIPT type = Text/JavaScript"
    function validate() {
    if ((document.myform.username.value.length <5) || (document.myform.password.value.length <5)) { //minimum 5 characters
    alert ("You must complete the user name and password fields");
    return false;
    }
    else {return true}
    }
    </SCRIPT>

  • #3
    New Coder
    Join Date
    May 2007
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I updated it useing this:
    Code:
    <?
    require('config.php');
    ?>
    
    <?php include('header.php'); ?>
    
    <h2>User Login</h2>
    
    <form name = "myform" method="post" action="logon_user.php" onsubmit = "return validate(this.Submitbutton)">
    
    <table>
    <tr><td>Username:</td><td><input name="username" type="text" /></td></tr>
    <tr><td>Password:</td><td><input name="password" type="password" /></td></tr>
    </table>
    
    <input type="submit" name="Submitbutton" value="Submit" class="button" /> <input type="reset" name="Submit2" value="Reset" class="button"/>
    
    <SCRIPT type = Text/JavaScript"
    function validate() {
    if ((document.myform.username.value.length <5) || (document.myform.password.value.length <5)) { //minimum 5 characters
    alert ("You must complete the user name and password fields");
    return false;
    }
    else {return true}
    }
    </SCRIPT>
    
    
    <?php include('footer.php'); ?>
    Doesn't seem to work though...

  • #4
    Regular Coder Nischumacher's Avatar
    Join Date
    Oct 2005
    Location
    Bombay, India
    Posts
    196
    Thanks
    0
    Thanked 2 Times in 2 Posts
    i DoN'T KNoW MuCH aBouT PHP... BuT iT SeeMS You aRe MiSSiNG THe FoRM CLoSiNG TaG... </form>...
    - NS 666
    .net DEVILoper

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Posts
    679
    Thanks
    0
    Thanked 16 Times in 15 Posts
    Code:
    <SCRIPT type = Text/JavaScript"
    should be
    Code:
    <script type="text/javascript">
    Last edited by rwedge; 05-14-2007 at 03:06 PM.

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,080
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by rwedge View Post
    Code:
    <SCRIPT type = Text/JavaScript"
    should be
    Code:
    <script type="text/javascript">

    HTML (unlike Javascript) is not case sensitive, but the missing " is indeed important! Thanks for spotting this!
    Last edited by Philip M; 05-14-2007 at 04:16 PM.

  • #7
    New Coder
    Join Date
    May 2007
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks guys This is a great forum. Im going to stick around if thats ok


  •  

    Posting Permissions

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