Hey,
I thought I would easily be able to force a variable out of a function by making it global, but that didn’t work, and I’ve spent hours on workarounds that have mangled my login script. This is what I want to achieve:
login.php
[code=php]if (_checkLogin($username, $password, $remember) !== true) {
$message = _checkLogin($username, $password, $remember);
} else {
redirect(‘http://www.mydomain.com/account.php’);
}
login.inc.php (include page with all the functions)
[code=php]if (mysql_num_rows($result) == 1) {
…(this part works)…
return true;
} else if (mysql_num_rows($result) !== 1 && mysql_num_rows($result2) == 1) {
session_defaults();
$error = “You need to confirm your account before you can login. Check your inbox of the email address you provided at signup.”;
return false;
} else {
session_defaults();
$error = “Sorry, but that username/password combination doesn’t exist. Try <a href=”forgotpass.php”>Forgot Password</a>.”;
return false;
}
but right now I have to have this in order to pass something outside of the function (using return):
[code=php]if (mysql_num_rows($result) == 1) {
…(this part works)…
return true;
} else if (mysql_num_rows($result) !== 1 && mysql_num_rows($result2) == 1) {
session_defaults();
return “You need to confirm your account before you can login. Check your inbox of the email address you provided at signup.”;
} else {
session_defaults();
return “Sorry, but that username/password combination doesn’t exist. Try <a href=”forgotpass.php”>Forgot Password</a>.”;
}
That way I could just echo $error. I thought this would be simple, but now my script doesn’t work right and I am confusing myself. Any help would greatly be appreciated