Page 1 of 1

Need help with this code

Posted: Sun Jun 19, 2005 10:32 am
by bouboule
Something is wrong with this code. When I post this code with out the part between the ======================= , everything works fine, every echos shows when told to and all the work is done like its supposed to, but as soon as I slap the code between the 2 ======================= , nothing happens on the page, just a blank page... I cant figure this out. Could anyone help me?

Code: Select all

<?php
include("auth.php");
include("get_users.php");

$usern=$_POST['usern'];
$passw=$_POST['passw'];
$userfound="false";
$goodpass="false";

echo "Username= " . $usern . "<br>";
echo "Password= " . $passw . "<br>" . "<br>";

$fp = fopen("users.txt", "r");
$data = fread($fp, filesize("users.txt"));

$brake = explode("\n",$data);

foreach($brake as $values){

echo $values . "<br>";
$temp = explode("|",$values);

    foreach($temp as $value){
      echo $value . "<br>";
    }

//=====================================

if ($temp[0]==$usern){
    if (temp[1]==$passw){
        $userfound = "true";
        $goodpass = "true";
        break;
    }else{
        $userfound = "true";
        $goodpass = "false";
        break;
    }
}else{
    $userfound = "false";
    $goodpass = "false";
}

//=====================================
    
}// end foreach

if ($userfound=="true"){
  echo "User found!!!" . "<br>";
}else{
  echo "User not Found!!!" . "<br>";
}

if ($goodpass=="true"){
  echo "Password Good!!!" . "<br>";
}else{
  echo "Password Wrong!!!" . "<br>";
}

?>
Basically what this code does is my flash sends 2 varialbes to this php, usern and passw. Then php opens the user.txt file and cuts the lines into segments (the file is in the following order: username|password|title|index). Then it cuts the lines into more segments so that finally the variable $temp[0] controls the username and temp[1] controls the password. But for some reason, nothing shows up when I slap the other code in.
Thank you verry much in advance.

Posted: Sun Jun 19, 2005 10:36 am
by hawleyjr
Welcome to DevNet. Please review Posting Code in the Forums.

viewtopic.php?t=21171

Code: Select all

include("auth.php");
include("get_users.php");
 
$usern=$_POST['usern'];
$passw=$_POST['passw'];
$userfound="false";
$goodpass="false";
 
echo "Username= " . $usern . "<br>";
echo "Password= " . $passw . "<br>" . "<br>";
 
$fp = fopen("users.txt", "are");
$data = fread($fp, filesize("users.txt"));
 
$brake = explode("\n",$data);
 
foreach($brake as $values){
 
	echo $values . "<br>";
	$temp = explode("|",$values);
 
	foreach($temp as $value){
		echo $value . "<br>";
	}
 
=====================================
 
	if ($temp[0]==$usern){
		if (temp[1]==$passw){
			$userfound = "true";
			$goodpass = "true";
			break;
		}else{
			$userfound = "true";
			$goodpass = "false";
			break;
		}
	}else{
		$userfound = "false";
	$goodpass = "false";
	}
 
=====================================
 
}// end foreach
 
if ($userfound=="true"){
	echo "User found!!!" . "<br>";
}else{
	echo "User not Found!!!" . "<br>";
}
 
if ($goodpass=="true"){
	echo "Password Good!!!" . "<br>";
}else{
	echo "Password Wrong!!!" . "<br>";
}