Reply to changing old values to new values

Your name:

Reply:


Posted by programming on 04/19/07 01:02

I just would like to re-explain the problem i am having as i had not
received any posts, so i might of explained in poorly.

The problem i am having is NOT parse error related, more or less a
problem in my logic. Ok , well what is happening is i am getting my
values in member.txt fields ok from reading it, but when i attempted
to write those values back to the member.txt file with updated string
values, my member.txt file is cleared of all values, and i think my
array is been wiped.

Here is the updated code:

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

//Store profile in username.txt
$fileName .= "../username/member";
$fileName .= $_POST['user_id'];
$fileName .= ".txt";
$handle = fopen($fileName, "w");
fwrite($handle, $_POST['form1']);
fclose($handle);

// build record into string from post values
$update = $_POST['user_id'] . "|" . $_POST['password'] . "|" .
$_POST['lastname'] . "|" . $_POST['firstname'] . "|"

$fileName = "../username/member.txt";
//set line to edit
//get file into an array
$contents=file($fileName);
//set the file name

$edit_line = $_GET['record_id'];
//replace original record with new record
$replace_text =$update;

// replace specified array index (user to update) with built string
$contents[$edit_line] = $replace_text;
// Strip carrage-returns
for($c = 0; $c < count($contents)-1; $c++)
{
$contents[$c] = str_replace( "n", "", $contents[$c] );

}
// write array to file
if (!$fp = fopen($fileName,"w")) { die("Cannot open file"); }

if($_GET['record_id']==$contents[$edit_line])
fwrite($fp,implode("n",$contents));
//fwrite($fp,$str);


fclose($fp);

}
else
{
if(!isset($_POST[Submit])){
// read content from file and place into array, this is used to put
initial content into form
$fc=file("../username/member.txt");
$userid_no = $_GET['record_id'];
$line = split("|",$fc[$userid_no]);
$user_id = $line[0];
$password = $line[1];
$firstname = $line[2];
$lastname = $line[3];
$email = $line[4];
}
}

?>



Cheers,
Peri

[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

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