Does anyone else see the problem here? i get ""userdetails did not match""
But the $myusername is set correct.

error_reporting(E_ALL);

if($_POST['tSubmit']){
$points = $_POST['pointamount'];
$price = $_POST['price'];
$reciever = $_POST['reciever'];
$mypassword = $_POST['mypassword'];	
$myusername = $_POST['myusername'];	
include "../db_connect.inc.php";

$sql= "SELECT password, loginid FROM login WHERE username = '$myusername'"; 
$result = mysql_query($sql) or die("Couldn't execute query") ; 
$userDetails = mysql_fetch_assoc( $result ); 

// We should only get 1 result other wise error 
if (count($userDetails)  == 1) //this gives the "userdetails did not match" error
{
  // Compare the passwords 
  if (sha1($_POST['mypassword']) == $userDetails['password']) 
  {
  
  ////If myusername do not have a storage of points
  if(!is_file("../u/txt/userPoints/".$myusername.".txt")){
	$ourFileName = "../u/txt/userPoints/".$myusername.".txt";
	$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
	fclose($ourFileHandle);
	$myFile = "../u/txt/userPoints/".$myusername.".txt";
	$fh = fopen($myFile, 'w') or die("can't open file");
	$stringData = "0";
	fwrite($fh, $stringData);
	fclose($fh);}else
  
  ////Check myusername's points
	$filename = "../u/txt/userPoints/".$myusername.".txt";
	$handle = fopen($filename, "r");
	$userPoints = fread($handle, filesize($filename));
	fclose($handle);
///If the user do not have enough points
	if($userPoints < $points){header("location: ../result.php?tp=nep");
///If the user send points to himself
	}elseif($reciever == $myusername){
		header("location: ../result.php?tp=rem");}
		
///Check if the reciever exist as a memeber
$sql= "SELECT `oginid FROM login WHERE username = '$reciever'"; 
$result = mysql_query($sql) or die("Couldn't execute query") ; 
$recieverDetails = mysql_fetch_assoc( $result );
mysql_free_result($result);
if (count($recieverDetails)  == 1) 
{
	if ($_POST['reciever'] == $recieverDetails['username'])
  {
	  ///Insert into MYSQL
	  $query = "
            INSERT INTO `ue-userfile2` (
              `from`,  `to`, `points`, `price`,`created`
            )
            VALUES ('{$userid}',
                '{$myusername}', '{$reciever}', '{$points}', {$price}, NOW()
            )";
			$result = mysql_query($query);
			if(!$result){header("location: ../result.php?tp=swwm");}
////The query was successful, now take away the points from myusername
	$filename = "../u/txt/userPoints/".$myusername.".txt";
	$fh = fopen($filename, 'w') or die("can't open file");
	$stringData = $userPoints - $points;
	fwrite($fh, $stringData);
	fclose($fh);
header("location: ../result.php?tp=snsi&r=".base64_encode($reciever)."");


  }
	
	
}else header("location: ../result.php?tp=nsu");


	

  
  
  
  
  
  
  } 
  else 
  { 
      // Incorrect password for username 
	  echo "wrong password";
  } 
} 
else 
{ 
  // Incorrect login somewhere 
  echo "userdetails did not match";
}  
}

Recommended Answers

All 2 Replies

print the contents of the _post array, just to ensure they are what you expect, sometimes the error is not where you expect

Member Avatar for diafol

// Incorrect login somewhere

Perhaps if you tied down the error a little more rigorously? More error trapping.

I have to be honest I can't make head nor tail of the code flow due to your indenting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.