clanstyles Posted October 18, 2007 Share Posted October 18, 2007 <?php require_once("class.query.php"); require_once("class.forms.php"); require_once("functions.php"); class user { var $username = ""; var $password = ""; var $email = ""; var $status = 0; #################### # Check to see if # a user is logged in. function isLoggedin() { if(isset($_SESSION['username']) && isset($_SESSION['password'])) return true; return false; } ################### # Auto Login Check function checkLogin($username, $password) { $sql= new mysqlQuery(); $sql->mysqlQuery(); $sqlerror = "select * from users where username='$username' and password='$password' LIMIT 1"; $results = $sql->query($sqlerror) ? "true" : "false"; if($results) { $array = $sql->fetch_array($sqlerror); $this->username = $username; $this->password = $password; $_SESSION['username'] = $username; $_SESSION['password'] = $password; $_SESSION['email'] = $array['3']; } $sql->close(); } ################## # Build Login Form function buildLogin() { if (isset($_POST['username']) && isset($_POST['password'])) $this->checkLogin(cleanstring($_POST['username']), cleanstring($_POST['password'])); if(!$this->isLoggedin()) { $forms = new forms(); $forms->createFormBlank("login"); $forms->createTextBoxAdv("Username: ", "username", 12, "if (this.value == '') { this.value = 'Username'; }", "if (this.value == 'Username') { this.value = ''; }", "", "Username", "0"); echo "<br />\n"; $forms->createTextBoxAdv("Password: ", "password", 12, "if (this.value == '') { this.value = 'Password'; }", "if (this.value == 'Password') { this.value = ''; }", "", "Password", "1"); echo "<br />\n"; $forms->createSubmit("submit", "submit"); $forms->endForm(); } } } ?> All the information is being obtained correctly. I have echoed it there isno problem there. The problem lies with it not saving the login info. <?php session_start(); date_default_timezone_set("Etc/GMT-5"); require_once("includes/class.user.php"); $user = new user(); if($user->isLoggedin()) { echo "<a href\"".session_destroy()."\">Logout</a>"; echo date("h:i:s", time()); } else $user->buildLogin(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/73740-login-help-using-sessions/ Share on other sites More sharing options...
cooldude832 Posted October 18, 2007 Share Posted October 18, 2007 if($user->isLoggedin()) { echo "<a href\"".session_destroy()."\">Logout</a>"; echo date("h:i:s", time()); } I didn't even read all the obdc, but you can't make a link to a php function that will actually run session_destroy and place its return in the echo (which is nothing) You need to link to a separate page that has session_destroy in it. as a function. Quote Link to comment https://forums.phpfreaks.com/topic/73740-login-help-using-sessions/#findComment-372109 Share on other sites More sharing options...
clanstyles Posted October 18, 2007 Author Share Posted October 18, 2007 reguardless, I removed that. It still doesn't work. It makes it so that on the first accept the page is Blank. Then I refresh, you are logged in no matter what. Then sometimes you logout or are loggedin. Quote Link to comment https://forums.phpfreaks.com/topic/73740-login-help-using-sessions/#findComment-372461 Share on other sites More sharing options...
clanstyles Posted October 18, 2007 Author Share Posted October 18, 2007 Yeah live test: DebateATopic.com Real Login info: username: me password: me Quote Link to comment https://forums.phpfreaks.com/topic/73740-login-help-using-sessions/#findComment-372490 Share on other sites More sharing options...
clanstyles Posted October 19, 2007 Author Share Posted October 19, 2007 bump please. Quote Link to comment https://forums.phpfreaks.com/topic/73740-login-help-using-sessions/#findComment-372881 Share on other sites More sharing options...
clanstyles Posted October 19, 2007 Author Share Posted October 19, 2007 Bring Up My Post Quote Link to comment https://forums.phpfreaks.com/topic/73740-login-help-using-sessions/#findComment-373362 Share on other sites More sharing options...
clanstyles Posted October 21, 2007 Author Share Posted October 21, 2007 Bring Up My Post Quote Link to comment https://forums.phpfreaks.com/topic/73740-login-help-using-sessions/#findComment-374890 Share on other sites More sharing options...
cooldude832 Posted October 21, 2007 Share Posted October 21, 2007 No one is going to help you if you can't even explain the problem right, you obviously don't realize what your own code does if it is yours. Quote Link to comment https://forums.phpfreaks.com/topic/73740-login-help-using-sessions/#findComment-374891 Share on other sites More sharing options...
clanstyles Posted October 22, 2007 Author Share Posted October 22, 2007 No one is going to help you if you can't even explain the problem right, you obviously don't realize what your own code does if it is yours. First off, it is mine, I don't understand why sometimes it THINKS i'm logged in and other times it doesn't The $user->isLoggedin() triggers randomly. letting you knowif you are logged in or not. If you test it you will see. Sometimes, you login, sometimes your logged out. Reguardless if you have the correct information. It does know to check. Sorry for not supplying the correct informatin. I though I had explained it perfectly. But I guess not. Quote Link to comment https://forums.phpfreaks.com/topic/73740-login-help-using-sessions/#findComment-375585 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.