Computing.Net > Forums > Web Development > PHP - saving a file

PHP - saving a file

Reply to Message Icon

Original Message
Name: rhawkes241
Date: September 18, 2005 at 03:10:57 Pacific
Subject: PHP - saving a file
OS: Windows xp
CPU/Ram: Athlon XP 1700, 512SD
Comment:

Hi,

How would you create a basic php sctript to save a value entered on a website into a plain text file on the server?

For instance, if a user enters "1" into a text box and submits the value, how can a text file be saved with the value of "1"?

I'm new to PHP and just starting out, but its something which I'd like to know for developing a small application as im learning.

Thanks in advance


Report Offensive Message For Removal

Response Number 1
Name: Michael J (by mjdamato)
Date: September 18, 2005 at 10:48:58 Pacific
Subject: PHP - saving a file
Reply: (edit)

PHP File System Functions

By the way, using files to save/retrieve information is very inneficient and can be easily corrupted. I suggest you look into using a database ont he back-end.


Report Offensive Follow Up For Removal

Response Number 2
Name: FBI Agent
Date: September 19, 2005 at 06:49:21 Pacific
Subject: PHP - saving a file
Reply: (edit)

i would suggest using this part of the site

you just read on how to open it then down at the bottom before "user contributed notes" there's fread and fwrite, check into those. also, dont forget to fclose your file after you're done with it.

Michael J would also be correct on what he's saying, however, i already know that you're making a counter of your webpages so that should be just fine using a flat file, but when ou want to start saving some big things in files, start looking towards a database, they're really not all that complicated at all, just get PHPMyAdmin and it's a snap

FBI Agent

AIM: EliteAssassin187


Report Offensive Follow Up For Removal

Response Number 3
Name: rhawkes241
Date: September 19, 2005 at 15:50:42 Pacific
Subject: PHP - saving a file
Reply: (edit)

Alright many thanks for your responses - I'll be looking into it further now I have a better idea of what to look for - the fread and fwrite seem pretty simple.


Report Offensive Follow Up For Removal

Response Number 4
Name: thtjen
Date: September 28, 2005 at 00:50:52 Pacific
Subject: PHP - saving a file
Reply: (edit)

since you guys are on this topic, could you tell me how can i extract the text box data from one page to another?! i tried saving the text in the textbox in an array on the first website like so:<textarea name="Text[t]" cols="70" rows="30"></textarea>// and calling the array name Text[] on another page but nothing comes out. could i call a variable (array) that i stored on a previous webpage to another webpage?! please help. Thanks.
btw, i tried the link but nothing comes out.


Report Offensive Follow Up For Removal

Response Number 5
Name: thtjen
Date: September 28, 2005 at 00:54:15 Pacific
Subject: PHP - saving a file
Reply: (edit)

with the "t" included in the "Text[t]" when calling


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: PHP - saving a file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software