Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

document_root and fopen function with input form

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I have two files in HTML and PHP (I'm not using mySQL at all right now) where I have a short input form on the first page and a second page that displays the results. I need to change them so that the input form writes to a separate text file and I have a lot of questions but right now my questions are limited to the DOCUMENT_ROOT and _SERVER statements and the fopen function statements.

This is what I have right now in the index.php to append to a text file:
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$myFile=fopen("$DOCUMENT_ROOT/guestlist.txt","a+");

This is what I have in my display page to read from the text file. It will eventually display an HTML table of the results.:
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$myFile=fopen("$DOCUMENT_ROOT/guestlist.txt","r");

Can anyone tell me if this is even close to correct? I guess I'm most confused about everything after the '=' sign on the first line.

Thank in advance for any answers!

J. Allen

 
it's a teeny, tiny, wafer thin ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic