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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.