update first name in file.txt

hi there
I need some help to figure out how to update a persons directory in text file.
so, i got a form where i submit persons information, such as first and last name,
address, and phone number. so far every thing works out fine (text file is created and i am able to write and read), but when I try
to update first name and last name, nothing changes in the text file. the zipcode state, and
everything in the address updetes only the first name and last name dont…
any help would be very appriciated
thanks in advance
Lary

Could you post the code that isn’t working?

here is the code:

Telephone Directory <?php if($_POST["fname"]!="" && $_POST["lname"]!="" && $_POST["address"]!="" && $_POST["city"]!="" && $_POST["state"]!="" && $_POST["zip"]!="" && $_POST["phone"]!="") { $fname = addslashes($_POST["fname"]); $lname = addslashes($_POST["lname"]); $address = addslashes($_POST["address"]); $city = addslashes($_POST["city"]); $state = addslashes($_POST["state"]); $zip = addslashes($_POST["zip"]); $phone = addslashes($_POST["phone"]); $out = $lname . ", " . $fname . ", " . $address . ", " . $city . ", " . $state . ", " . $zip . ", " . $phone . "\n"; if (isset($_POST["update"])) { $all = file("phone_dir.txt"); for($i=0; $i0) echo "

Entry Updated Successfully.


"; //Return to Directory"; else echo "

Entry Update was Unsuccessful.

Return to Directory


"; } else { $file=fopen("phone_dir.txt","a+"); if($file) { if(flock($file,LOCK_EX)) { if(fwrite($file,$out)) { echo "

New Entry Successfully Added.


";//Return to Directory
"; } else { echo "

New Entry was Unsuccessful.

Return to Directory


"; } flock($file,LOCK_UN); } else { echo "

Error Locking Directory File.

Return to Directory


"; } fclose($file); } else echo "

The directory did not open sucessfully.

Return to Directory


"; } } else { echo "

You must enter a value in each field. Click your browser's back button to return to the form.


"; } ?>

Return to Directory

Sponsor our Newsletter | Privacy Policy | Terms of Service