Jump to content

FILES doubt


Gurzi

Recommended Posts

Hy there...

I have one question about managing files..

I have one form with 2 input type="text" and i want to write the $_POST data on the file..

Ok, it works, but my problem is i want that the next registration be on a new line, so, when i open te agenda.txt(agenda is adress book in Portuguese, btw  ;D) the data is written on a new line...
I wrote the "\n" but i a single char appears on the .txt and the new registration occurs next the last one , instead of a new line

the code is :
if(isset($_POST['Adicionar']))
{
$handle = @fopen($file, "a+")
OR die("Failed to open the file " . $file . "\n");
    $nome = $_POST['Nome'];
$email = $_POST['Email'];


@fwrite($handle, $nome . "|-|");
@fwrite($handle,$email );
@fwrite($handle, "\n");

}

thnks a lot
Link to comment
https://forums.phpfreaks.com/topic/16399-files-doubt/
Share on other sites

ok, i didn't know that point...

i tryed a different way, and it's fine.. but i dont understand why.. because i think that is the same thing :

$handle = @fopen($file, "ab+")  OR die("Failed to open the file " . $file);
    $nome = $_POST['Nome'];
$email = $_POST['Email'];

    $gravar = $nome  ."|-|". $email;
@fwrite($handle, "$gravar\r\n");

and now, the file jump to the next line

Link to comment
https://forums.phpfreaks.com/topic/16399-files-doubt/#findComment-68270
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.