Sunday, 29 September 2013

How to increment a single number in a text file with PHP

How to increment a single number in a text file with PHP

I am writing a VoteBox (like/dislike box) in html and I cannot find how to
do this anywhere.
Basically, there will be a like and a dislike button. When one of them
gets clicked, it will forward the user to a page. And in that, I want some
PHP code that will increase the number in upvotes.txt/downvotes.txt
I have tried doing it with a database but the problem is I want anyone to
be able to use this without any setup.
i also want the front page to display the number of upvotes and the number
of downvotes
so its kinda like this (most of this isn't real code BTW im new to PHP):
//this is the code for upvote.html
$upvotes = get_data_from_TXT_file
$changedupvotes = $upvotes + 1
set_data_in_txt_file_to_$changedupvotes
Sorry if i havent explained this very well
Any help appreciated

No comments:

Post a Comment