PHannum Posted May 8, 2014 Share Posted May 8, 2014 Can anyone help me as to what this means? Notice: Undefined index: logged_in in /home/students/phannum/public_html/n413/class/Login/login.inc.php on line 7 Fatal error: Call to undefined function issest() in /home/students/phannum/public_html/n413/class/Login/login.inc.php on line 10 Here is my code: <?php require_once('config.inc.php'); require_once('functions.inc.php'); session_start(); if ($_SESSION['logged_in'] == true) { redirect('#'); } else { if ((!issest($_POST['username'])) || (!issest($_POST['password'])) OR (!ctype_alnum($_POST['username'])) ) { redirect('#'); } $mysql = @new mysql($dbhost, $dbuser, $dbpwd, $dbname); if (mysqli_connect_errno()) { printf("Unable to connect to database: %s", mysqli_connect_error()); exit(); } $username = $mysqli->real_escape_string($_POST['username']); $password = $mysqli->real_escape_string($_POST['password']); $sql = "SELECT * FROM users WHERE username = '" . $username . "' AND password = '" . md5($password) . "'"; $result = $mysqli->query($sql); if(is_object($result) && $result->num_rows == 1) { $_SESSION['logged_in'] = true; redirect('#'); } else { redirect('#'); } } ?> Thanks! Quote Link to comment Share on other sites More sharing options...
trq Posted May 8, 2014 Share Posted May 8, 2014 Change: if ($_SESSION['logged_in'] == true) { To: if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) { Quote Link to comment Share on other sites More sharing options...
PHannum Posted May 8, 2014 Author Share Posted May 8, 2014 Thank you for your help! But now it is giving me this error: Fatal error: Call to undefined function issest() in /home/students/phannum/public_html/n413/class/Login/login.inc.php on line 10 Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 8, 2014 Share Posted May 8, 2014 C'mon man. issest is not the same as isset Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted May 8, 2014 Share Posted May 8, 2014 I think the handling of booleans also needs some practice. What exactly is if ($some_var == true) supposed to do? Are you afraid that the variable itself somehow isn't true enough and needs some extra trueness? Then why stop there? Why not: if (((($some_var == true) == true) == true) == true) Maybe it's even truer now. Personally, however, I'd simply test the value: if ($some_var) Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 8, 2014 Share Posted May 8, 2014 @Jacques1:I wouldn't beat him up too bad about that - I see it all the time, even by advanced users. But, that is a pet peeve of mine. Even worse is when I see someone use an if/else condition where there is no logic included for the if() condition and only the else condition because the user wasn't able to properly create the condition. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.