HeroSteve Posted December 9, 2012 Share Posted December 9, 2012 Hey guys, i'm a beginner to php so im trying to use this login registration system as a firm and strong foundation from this source "http://www.ineedtuto...em-php-tutorial" and i've met an error that im trying to fix for login.functions.php file on line 6 for syntax error, unexpected 'else' (T_ELSE). The code is: <?php function isLoggedIn() { if (isset($_SESSION['loginid'])){ t echo $_SESSION['username']; { { return true; // the user is loged in } else { return false; // not logged in } return false; } function checkLogin($u, $p) { global $seed; // if (!valid_username($u) || !valid_password($p) || !user_exists($u)) { return false; } $query = sprintf(" SELECT loginid FROM login WHERE username = '%s' AND password = '%s' AND disabled = 0 AND activated = 1 LIMIT 1;", mysql_real_escape_string($u), mysql_real_escape_string(sha1($p . $seed))); $result = mysql_query($query); if (mysql_num_rows($result) != 1) { return false; } else { $row = mysql_fetch_array($result); $_SESSION['loginid'] = $row['loginid']; $_SESSION['username'] = $u; return true; } return false; } ?> I've done some minor edits on session_is_registered with $_SESSION due to php updates but still dont know how to overcome the error. Can you please help me on this particular problem and some explainations on the problem would be wonderful. Thanks Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/ Share on other sites More sharing options...
trq Posted December 9, 2012 Share Posted December 9, 2012 Have a look at line 6. Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/#findComment-1398341 Share on other sites More sharing options...
HeroSteve Posted December 9, 2012 Author Share Posted December 9, 2012 I cleared that mistake but still recieving the same error. Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/#findComment-1398344 Share on other sites More sharing options...
bugcoder Posted December 9, 2012 Share Posted December 9, 2012 rewriting first function for you and look for what is difference between yours and mine function isLoggedIn() { if (isset($_SESSION['loginid'])){ echo $_SESSION['username']; return true; // the user is loged in } else { return false; // not logged in } return false; } Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/#findComment-1398347 Share on other sites More sharing options...
HeroSteve Posted December 9, 2012 Author Share Posted December 9, 2012 rewriting first function for you and look for what is difference between yours and mine function isLoggedIn() { if (isset($_SESSION['loginid'])){ echo $_SESSION['username']; return true; // the user is loged in } else { return false; // not logged in } return false; } Thanks for the help much appreciated Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/#findComment-1398351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.