Reply to edit lines in txt file

Your name:

Reply:


Posted by programming on 04/25/07 00:54

Hey all i am trying to write data that i have stored in a session back
to a member.txt, but i am unable to work out why it wont write. It
displays the data i have stored in the session ok, but it wont do the
next step! I have used a similiar script in another part of my web
page which works, but this one won't. From my understanding it has
something to do with if statement if($data[0] == $user_id), so i might
be trying to compare the previouis data to the current data stored in
the txt file properly. Any ideas?

Cheers,

Peri.


if(!isset($_POST[Submit])){


// Load the lines into an array; newlines are still attached
$fc=file("../username/member.txt");

foreach ($fc as $line)
{
$data = explode("|", $line);
if($data[0] == $_SESSION['valid_user'] ){
$user_id = $data[0];
$password = $data[1];
$firstname = $data[2];
$lastname = $data[3];
$email = $data[4];
}
}
}
else{
if(($firstname = $_POST["firstname"])
&&($password = $_POST["password"])
&&($lastname = $_POST["lastname"])
&&($email = $_POST["email"])){
$count = 0;
// Load the lines into an array; newlines are still
attached
$fc=file("../username/member.txt");
//open same file and use "w" to clear file
$f=fopen("../username/member.txt","w");
//loop through array using foreach
foreach ($fc as $line)
{
$str_line = $line;
$data = explode("|", $line);

if($data[0] == $user_id){

$str_new = $user_id."|".$password."|".
$firstname."|".$lastname."|".$email."\n";
fwrite($f,$str_new);
} else{
fwrite($f,$str_line);
}
}
if(($_POST["lastname"])&&($_POST["firstname"])==TRUE){
header("Location: ./user_home.php");
}
fclose($f);
}
}

?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация