Jump to content

Recommended Posts

Hello!

 

This script is parsing username, fname, and lname correctly, but it is only sending the first letter of the password!

 

Help!

 

$sql = 'SELECT username, password, fname, lname FROM authentication WHERE 1'; 	
$sql_result = mysql_query($sql,$dbh) or die ("Couldn't execute username query.");

$totalusers = 0;
while ($row = mysql_fetch_array($sql_result)) 
	{
		$user [$totalusers] = $row["username"];
		$pass [$totalusers] = $row["password"];
		$fname [$totalusers] = $row["fname"];
		$lname [$totalusers] = $row["lname"];
		$totalusers = $totalusers + 1;}
...
...


$checkusers = 0;
while($checkusers < $totalusers) { 
        if($_POST['username'] == $user [$checkusers] && $_POST['password'] == $pass [$checkusers]){ 


$_SESSION['name'] = $user [$checkusers];
$_SESSION['realname'] = $fname [$checkusers]." ".$lname [$checkusers]; //adds the users data to the php session
$_SESSION['pass'] = $pass [$checkusers];
   $logink = true;
   }
   $checkusers = $checkusers + 1;
   }

//insert html for sucessfull log on here
//you can use  . $_SESSION['name'] . for username
// replace name with realname, url, email to display different name
if ($logink == true){
?> 
You are logged in.<br>
You may logout <a href="logout.php">here</a>.

</body>
</html>


<?php
}
    if($logink !== true) { 

// Some TESTING

echo $user [$checkusers]; echo $checkusers; echo $totalusers; $run = 3; echo $run; echo $user [0]; echo $user [1]; echo $user [2]; $pass [0] = "test"; echo $pass [0]; echo $pass [1]; echo $_POST['username']; echo $_POST['password']; $test [0] = "monkey"; $test [1] = "bananas"; echo $test [0]; echo $test [1]; echo $fname [1]; echo $lname [1];

// End testing

?>
<br>Login failed, bad username/password
<?

} 

Link to comment
https://forums.phpfreaks.com/topic/72040-solved-only-sending-first-letter/
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.