new to php - write new info to file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dssquirt
Forum Newbie
Posts: 1
Joined: Sat May 04, 2002 6:23 pm

new to php - write new info to file

Post by dssquirt »

Hi.

I'm taking a web server class and for our last project we need to write a php program that takes information off of a form and adds it to a text file. We are inputting user ids and passwords adding them to the file and then letting users change the passwords if they so desire.

I am new to PHP and don't have time to read a book before this project is due. I know how to open a file and read from it, but how do I write information to it and save the file?

And if I want to check for information and then change it, is there an easy way to do it?

Thanks very much. I really want to learn PHP, and I guess I am getting a crash course. This project was just assigned and is due in 8 days. I had no background in PHP before this and I'm picking it up as fast as I can.

Dssquirt
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

Well you need to check out some file handling functions. Well to write/save to a file its:

$fp = fopen( $file, 'w'); // a is to open the file to ammend info to it
fputs($fp, "hello... from a file!");

$read = fgets($file, 255);

echo"<b>Contents</b>: " . $read;

fclose($fp);
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

I wish I had such a class that made me do an assignment like that! :P
HiDDeN
Forum Newbie
Posts: 2
Joined: Sun May 05, 2002 3:26 am
Location: Minsk
Contact:

Post by HiDDeN »

I wish I had such a class that made me do an assignment like that!
Well classes are not completely implemented in PHP it's just slowing down your code, furthermore your project is not such a complex thing to write tons of classes code.
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

Hi,

They are not talking about class in OO terms, they are talking about class as in learning, courses, training etc
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post by sam »

HiDDeN wrote:
I wish I had such a class that made me do an assignment like that!
Well classes are not completely implemented in PHP it's just slowing down your code, furthermore your project is not such a complex thing to write tons of classes code.
Ha Ha... That is classic :mrgreen:

Cheers Sam
Post Reply