www.webdeveloper.com
Results 1 to 3 of 3

Thread: checking for successful login

  1. #1
    Join Date
    Apr 2012
    Posts
    99

    checking for successful login

    I am trying to check if the user is successfully logged in. here is my code:

    Code:
    "loginUser.php",
        				{ 
            				username: $("#username").val(), password: $("#password").val() 
            			},
        				function(data){  
            				$("#loginStats").html(data);
    						var success = (data == true ? $('#login').html('<img src=images/loader.gif width=16 height=16 /> Now taking you to the member area...') : $('#login').html('<img src="images/red_x.png" width="24" height="24" /> Invalid Login.')); 
    						if(success) {
    							
    						}
            			}
    loginUser.php

    Code:
    foreach($_GET as $key => $value) {
    	$get[$key] = $value;
    }
    
    $username = $get['username'];
    $password = $get['password'];
    
    if(!empty($username) && !empty($password)) {
    	return true;
    } else {
    	return false;
    }
    }
    i enter values for both fields, but it is still returning false - invalid login. why?

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    remove

    Code:
    var success = (data == true ? $('#login').html('<img src=images/loader.gif width=16 height=16 /> Now taking you to the member area...') : $('#login').html('<img src="images/red_x.png" width="24" height="24" /> Invalid Login.')); 
    						if(success) {
    							
    						}
    insert

    Code:
    var content = (data == true) ? '<img src="images/loader.gif" width="16" height="16" /> Now taking you to the member area...' : '<img src="images/red_x.png" width="24" height="24" /> Invalid Login.';
    
    $('#login').html(content);
    what does this do?

    PHP Code:
    foreach($_GET as $key => $value) {
        
    $get[$key] = $value;

    try this one

    PHP Code:
    $username $_GET['username'];
    $password $_GET['password'];

    if(!empty(
    $username) && !empty($password)){return true;}
    else{return 
    false;} 
    Last edited by Padonak; 04-29-2012 at 02:55 AM.
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Apr 2012
    Posts
    99
    hm, stll always returns false, even if i fill in values, or set values in the loginUser.php page...

    here is my code for each page:

    Code:
    $.get
        			(
        				"loginUser.php",
        				{ 
            				username: $("#username").val(), password: $("#password").val() 
            			},
        				function(data){  
            				$("#loginStatus").html(data);
    						
    						var success = (data == true) ? '<img src="images/ajax-loader.gif" width="16" height="16" /> Valid Login!  Now taking you to the members area...' : '<img src="images/red_x.png" width="24" height="24" /> Invalid Login.  Please try again.';
    
    						$('#loginContainer').html(success);
    
    						if(success) {
    							// do something here, like log them in - update db, set cookies, and redirect
    						}
            			}
        			)
    Code:
    <?php
    
    include 'db_connect.php';
    $username = $_GET['username']; 
    $password = $_GET['password']; 
    
    if(!empty($username) && !empty($password)){return true;} 
    else{return false;} 
    
    ?>

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