www.webdeveloper.com
Results 1 to 2 of 2

Thread: Login System Issue

  1. #1
    Join Date
    Jul 2011
    Posts
    18

    Login System Issue

    I have a login system that was working and now isn't. It seems to run the check on whether there is a username password, but upon submitting nothing happens. there is an access.php page that allows access to certain pages based on whether login has been done. that isn't passing through so I think something is wrong with the submit or the onLogin function but hopefully someone whos a pro can let me know. If you need to see the access or register page, let me know

    THANKS!!


    Here is my login page PHP
    PHP Code:
    <?php session_start(); ?>
    <script src="js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
    //<![CDATA[
                $(document).ready(function() {
                    
                    $("#loginform").validate({
                        rules: {
                            email: {
                                required: true,
                                email:true
                            },
                            password: {
                                required: true,
                            },
                        },
                        messages: {
                            password: "Please enter your password",
                            email: "Please enter a valid email address"
                        }
                    });
                });
                
                function OnLogin(){
                    var email = $('#email').val();
                    var password = $('#password').val();
                    
                    if ( email != "" && password != "" ){ 
                        
                            $.ajax({
                                    url:'lib/login.php',
                                    type:'POST',
                                    data:"email=" + email + "&password=" + password,
                                    async:false,
                                    success: function(str){
                                        
                                        if ( str.indexOf("SUCCESS") != -1 )
                                        {
                                            if ( $("#redirect").length > 0 && $("#redirect").val() != ""  ) 
                                                location.href = $("#redirect").val() + ".php";
                                            else
                                                location.reload();
                                            return;
                                        }
                                        else
                                        {
                                            if ( str.indexOf("PWD") != -1 )
                                            {
                                                alert("Please input the correct password.");
                                                $("#password").focus(); 
                                            }
                                            else if ( str.indexOf("UID") != -1 )
                                            {
                                                alert("Please input the correct email.");
                                                $("#email").focus();
                                            }
                                        }
                                    }
                                });
                        }
                            
                    }
                            
                function OnRegister(){
                    location.href = "register.php";
                }
                
                function OnLogOut(){
                    $.ajax({
                            url:'lib/logout.php',
                            type:'POST',
                            data:"logout=1",
                            async:false,
                            success: function(str){
                                
                                if ( str.indexOf("SUCCESS") != -1 )
                                {
                                    location.reload();
                                    return;
                                }
                            }    
                        });                
                }
    //]]>
    </script>
    <?php if( !isset($_SESSION['PHP_AUTH_USER']) ): ?>
    <h1>User Login</h1>
    <div id="login-form">
        
        <form id="loginform" name="loginform" method="post" onsubmit="OnLogin();return false;">
            <h3>Email</h3>
            <input type="text" name="email" id="email" />
            <h3>Password</h3>
            <input type="password" name="password" id="password" />
            <br />
            <input type="submit" class="login button" src="images/login.jpg" />
            <input type="button" class="register button" src="images/register.jpg" onclick="OnRegister()" />
        </form>
    </div>
    <?php else:?>
        <p>Thanks <strong><?=$user_name?></strong>, You are now logged in.</p>
        <p style="text-align:center"><input type="button" class="button" onclick="OnLogOut()" value="logout" /></p>
    <?php endif;?>
    Last edited by jschnyderite; 11-07-2011 at 11:01 AM.

  2. #2
    Join Date
    Jul 2011
    Posts
    18
    anyone have feedback on this?
    i tried variation of making the submit a button, image, and submit input and putting the actual function call within that input but no luck yet.

    i'm sorta in a bind. any help or guidance on what to look for is appreciated. thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles