chriscloyd Posted March 11, 2012 Share Posted March 11, 2012 I have a login form at http://cloydprojects.com you can login with username: test password test If you login the script works correctly, but if you type in the wrong info my session is not showing here is that I have. my login script <?php session_start(); ?> <link href="signUp.css" rel="stylesheet" type="text/css" /> <?php include("db.php"); include("classes/class.account.php"); $Acc = new account; $u = $Acc->clean($_REQUEST['usernameLogin']); $password = $Acc->clean($_REQUEST['passwordLogin']); $p = md5($password); $get = mysql_query("SELECT * FROM users WHERE username = '".$u."' and password = '".$p."'"); $find = mysql_num_rows($get); if ($find == 1) { $info = mysql_fetch_assoc($get); $_SESSION['LoggedIn'] = $info['uID'].'.'.$info['username'].'.'.$info['email']; } else { $_SESSION['LoggedFailed'] = '<div id="ErrorBox">Incorrect username/password!</div>'; } //there is more just not showing it here is my index script where the error should be showing! <div class="stylized"> <?php if(isset($_SESSION['LoggedIn'])) { echo '<h1> Welcome! </h1>'; echo '<a href="logout.php">logout!</a>'; } else { echo $_SESSION['LoggedFailed']; session_destroy(); ?> <form id="instantform" name="form" action="loginUser.php" method="post"> <h1>Login</h1> <label>Username <span class="small">The username you created!</span></label> <input type="text" name="usernameLogin" id="usernameLogin" /> <label>Password <span class="small">Case sensitive!</span></label> <input type="password" name="passwordLogin" id="passwordLogin" /> <button type="submit">Login</button></div> <div class="spacer"></div> </form> <?php } ?> </div> Link to comment https://forums.phpfreaks.com/topic/258697-php-session-not-echoing/ Share on other sites More sharing options...
xyph Posted March 11, 2012 Share Posted March 11, 2012 Why have different keys? Why not just store both messages in $_SESSION['loggedMessage']? If I type in incorrect information, I get 'Incorrect username/password!' and the login screen. I don't understand the issue. Link to comment https://forums.phpfreaks.com/topic/258697-php-session-not-echoing/#findComment-1326189 Share on other sites More sharing options...
chriscloyd Posted March 11, 2012 Author Share Posted March 11, 2012 I do not get the error message and the login screen Link to comment https://forums.phpfreaks.com/topic/258697-php-session-not-echoing/#findComment-1326192 Share on other sites More sharing options...
PFMaBiSmAd Posted March 11, 2012 Share Posted March 11, 2012 Do you have a session_start() statement in your second piece of code? Link to comment https://forums.phpfreaks.com/topic/258697-php-session-not-echoing/#findComment-1326204 Share on other sites More sharing options...
xyph Posted March 11, 2012 Share Posted March 11, 2012 Seems like a client-side error. I'm not sure. test/test isn't working any more. Link to comment https://forums.phpfreaks.com/topic/258697-php-session-not-echoing/#findComment-1326206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.