PHP Modifying Linux Text File

3 replies
Hi,

I have a PHP/HTML form that the user submits an ip address on, this ip address needs to be added to a specific file. On the form the user also selects the file to use...

The file system in this case is linux.

I have never used php with file / directory manipulation before.... PLEASE HELP>>

Thanx!!
#file #linux #modifying #php #text
  • Profile picture of the author ussher
    Here is a tutorial on how to use PHP to write to files in the filesystem.
    PHP Tutorial - File Write

    If its a straighforward append to the end of the list, then that should do it, If the IP address has to go in a specific location in the file, it wil get a little more complex.

    You will need to load the file into a variable then do a search and replace for the location it needs to go before writing it again.
    Signature

    "Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."

    - jamroom.net
    Download Jamroom free: Download
    {{ DiscussionBoard.errors[4587086].message }}
    • Profile picture of the author Tashi Mortier
      Another great starting place is the PHP manual:

      PHP: Filesystem Functions - Manual
      PHP: Directory Functions - Manual

      Make yourself a cup of tea and play around, look at the examples. Here's some pseudo code for you:

      display form:

      open directory
      display list of files in an <select>/<option> html-element
      allow creation of new file

      save ip:

      open/create relevant file
      write ip
      close file
      Signature

      Want to read my personal blog? Tashi Mortier

      {{ DiscussionBoard.errors[4607021].message }}
  • Profile picture of the author lordspace
    if you have time try to learn and do it yourself it might take you a couple of days but keep an open mind to learn new things otherwise you could hire somebody.
    I'm sure it'll cost you max 20-30$ ... unless you add more stuff to the task
    Signature

    Are you using WordPress? Have you tried qSandbox yet?

    {{ DiscussionBoard.errors[4696015].message }}

Trending Topics