Mobile app version of vmapp.org
Login or Join
Cofer257

: HELP! my login session is returning the users password instead of their username! I have my code set up to display the username in the nav bar however its displaying their password? nav.php

@Cofer257

Posted in: #Authentication #Html #Php #Session

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Cofer257

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

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.)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme