Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning 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
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

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

 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic