Keeping track

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
bluewalrus
Forum Newbie
Posts: 3
Joined: Tue Oct 07, 2008 1:03 am

Keeping track

Post by bluewalrus »

I've never written my own php i just started looking at php this past week and it looks similar to basic. So...I have a form on a page and is submitting to threw a php page i want the php page to number each submission so i created a txt file called "number" that text file only has a 0 in it. I think i wrote this code below so that it opens the text file reads the 0 adds one to it and then saves and closes it. If this code is correct for that then the only question i have is how do i call it back so i can reference it back on the form page to say the number that has been submitted? I'm gonna change the page to a php cause i can display html and css in that page the same correct?

Code: Select all

 
<?php
$num = "number.txt";
$increase = fopen($num, 'w');
$val = ($num + 1);
fwrite($increase, $val);
fclose($increase);
?>
 
Thanks for any suggestions you have.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Keeping track

Post by papa »

Well first of all $val is saying: number.txt + 1

Look at file_get_contents and give it another shoot.
Post Reply