<?php
//Login Module (Updated, isset now correct)
session_start();
if(!(isset($_SESSION['login']) && ($_SESSION['login'] != ""))) {
include('processor/ProcessLogout.php');
} else {
include('processor/ProcessLog.php');
}
?>
Problem is…it doesn’t work. I can’t seem to get it to validate to true T_T. I set $_SESSION[‘login’] in processor/assess_login.php. ProcessLog is merely a container for some divs and a form the form passes information to asssess_login (which then tells me whether a login has been successful or not). One displays a login form the other displays a logout form. Unfortunately, even though I get “Login Successful”… it’s rather worrying that $_SESSION[‘login’] refuses to change to ‘1’. (That’s what I do in assess_login if the login is successful. if it fails I set it to an empty string.
Now as far as I’m aware session_start() is supposed to remember this, but for some reason…it doesn’t o.o; So any tips on my bug hunting
There are compilation errors and taking away the ! does infact display the alternative, so I know that bit ‘is’ working it just isn’t evaluating to true.
Now… as for the assess_login…
if ($db_found) {
$member_username = quote_smart($member_username, $db_handle);
$member_password = quote_smart($member_password, $db_handle);
$sql = "SELECT * FROM $tblname WHERE username=$member_username AND passphrase=$member_password";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
//Validate there is a user
if($result) {
if($num_rows == 1) {
session_start();
$_SESSION['login'] = '1';
header("location: ../login_success.php");
} else {
session_start();
$_SESSION['login'] = "";
header("location: ../login_fail.php");
}
} else {
$error_msg = "Error Validating User! -1";
}
mysql_close($db_handle);
}
Bearing in mind it is buried somewhat. As I’ve said before I can’t get the login to stick and I know I’m missing something obvious I’ll be damned if I can figure out what though.
Your if statement is not correct:
should be