/    Sign up×
Community /Pin to ProfileBookmark

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) {

}
}[/CODE]

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;
}
}[/CODE]

i enter values for both fields, but it is still returning false – invalid login. why?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@PadonakApr 29.2012 — 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) {

}[/CODE]


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);[/CODE]


what does this do?

[code=php]foreach($_GET as $key => $value) {
$get[$key] = $value;
}
[/code]


try this one

[code=php]$username = $_GET['username'];
$password = $_GET['password'];

if(!empty($username) && !empty($password)){return true;}
else{return false;}[/code]
Copy linkTweet thisAlerts:
@droidusauthorApr 29.2012 — 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]


[CODE]<?php

include 'db_connect.php';
$username = $_GET['username'];
$password = $_GET['password'];

if(!empty($username) && !empty($password)){return true;}
else{return false;}

?>[/CODE]
×

Success!

Help @droidus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...