Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.