Jump to content

Importing from a txt file


kristen252

Recommended Posts

I am very new to php, but I am trying to use the following code to import data from a txt file that is saved on my server:

 

<?php

$filename="totals.txt";

$handle=fopen($filename,"r");

 

$contents=fread

($handle,filesize($filename));

 

echo($contents);

?>

 

The problem is that code imports the whole file- is there any way to import only part of the file?  Say the last part of the first line?  The txt file is generated by a form on my website and the form is automatically placing the persons ip address and I don't want that to show on our site.

 

Or maybe I'm just going about this the wrong way and there is a form you can use in php to allow the visitor to your site to post to a certain page on your site?

 

Any help or direction you could provide would be appreciated!  As I mentioned, I'm very new at this, but I would like to learn!

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.