I am trying to make a script that searches the file for a word that the user imputs and then if the word is there, it'll edit the number values after it (like a database just about, but i don't want to use MySQL). How would I go about writing to an exact spot in the file after i have found its position?
<?php
// Name = username
// pass = password
// both from a form or something on a previous page
$data = fopen("file.txt","r+");
if(!$data)
{
echo "Unable to open data file.";
exit;
}
while(!feof($data))
{
$buffer = fgets($data0, 4096);
$buffer2 = explode(":",$buffer);
if($buffer2[1]!=$name)
{
echo "User is not registered on that server.";
} else {
if($buffer2[2]!=$password)
{
echo "Password was invalid.";
} else {
// $buffer2[3] would be the
//numbers i want to edit
}
}
}
fclose ($data);
?>