A few days ago I needed to find a simple way to count the number of times a web page loaded. A script in the page had a variable that triggered an event to occur every so many page loads. I needed to use a counter to trigger the event the variable controlled. This little 93 Byte counter code is what I came up with: <?php file_put_contents('count.txt','1\n',FILE_APPEND); $count = count(file('count.txt')); ?> The first time the counter script runs it creates a file called count.txt then writes a number "1" and a carriage return into the first line of the file. From then onwards, every … [Read more...]
Using PHP to Send Data Between Webpages

Every now and again we web designers need to pass user input between pages. It could be a username or affiliate code that needs adding into a set of links; it could be details of a contact form that need passing over to a confirmation page before being sent to a database or email server; or it could be any other bit of information that a site visitor enters into one form that must be reproduced or used somewhere within another page or set of pages. Luckily, for those of us who haven't studied PHP, the recipe for passing information between pages contains few ingredients and is easy to follow … [Read more...]






