0

I have my code set up to display the username in the nav bar however its displaying their password?

nav.php

<li>
   <a href class="userName"><?php echo $_SESSION['userName'];?></a>
</li> 

connectivity.php

function SignIn() 
{ 
    session_start(); //starting the session for user profile page 
    if(!empty($_POST['user'])) //checking the 'user' name which is from Sign-In.html, is it empty or have some text 
    { 
        $user = $_POST[user];
        $pass = $_POST[pass];

            $query = "SELECT * FROM UserName where userName = '$user' AND pass = '$pass'";
            $query = mysql_query($query) or die(mysql_error()); 
        $row = mysql_fetch_array($query) or die(mysql_error());
        if(!empty($row['userName']) AND !empty($row['pass'])) 
        { 
            $_SESSION['userName'] = $row['pass']; 
            header("location: ../PHP/Cart.php");

        } else { 
            echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY..."; 
            } 
        } 
    } 
    if(isset($_POST['submit'])) 
    { 
        SignIn(); 
    } 

in the nav.php you can see its echoing the $_SESSION['userName'] however its displaying their password?

closed as off-topic by MrWhite, closetnoc, dan Oct 3 '15 at 0:59

  • This question does not appear to be about webmastering within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

1

This must be a clue:

$_SESSION['userName'] = $row['pass'];

You should also enable full error_reporting whilst developing. (It will throw up some other warnings.)

Not the answer you're looking for? Browse other questions tagged or ask your own question.