Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
11-15-2007, 07:09 PM #1
- Join Date
- Nov 2007
- Thanked 0 Times in 0 Posts
writing to a txt file using the pipe symbol?
i wrote this code to read from a text file using php, but when i go to add more info using a html form, it just adds the info but not in the right place.it needs to be in number order.
Any help please......
this is my text file:
this is the php file in which i use to read this file.
$file = fopen("welcome.txt", "r");
print "error! The file could not be opened";
// read file and print, line by line
this is my append to file PHP script but isnt working right:
$customerName = $_POST['name'];
if(!$customerName) // If name is not entered show error message
echo "Please enter your name to register.";
$filename = "seats.txt"; // File which holds all data
$content = "$customerName\n"; // Content to write in the data file
$file = fopen($filename, "a"); // Open the data file, file points at the end of file
$filewrite = fwrite( $file, $content ); // Write the content on the file
fclose( $file ); // Close the file after writing
if(!$filewrite) echo "Couldn't write the entry.";
echo "You are now registered, Click below to continue.";
11-15-2007, 07:18 PM #2
- Join Date
- Mar 2007
- Florida, USA
- Thanked 406 Times in 398 Posts
Post your form, an example of what you're submitting, and the unintended result. Also, I don't see any code dealing with numbers at all. Are you manually entering them?