Jump to content

Click Based Expiration Link


Recommended Posts

Hello,

 

I am new to PHP I typically work with .NET

 

I am trying to get this script to work that records an IP address and the number of times a user has clicked on a link to a .txt file, while expiring after a certain number of clicks (in this case, 3).  This script will record the first link click and IP address, but from there it doesn't log the additional attempts.  I would be grateful if some PHP savvy person can quickly look over this script and point out any obvious issues.

 

One line in particular i am questioning is the '&' in:

 

if (do_readfile_string(&$clicks,$filename)

 

 

 

Thanks ahead.

 

I zipped the 2 files and attached.

 

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/200088-click-based-expiration-link/
Share on other sites

The & is generally used for passing as reference, but afaik, it needs to be in the funciton declaration. Not the function call.

 

It works either way. So it is just being passed by reference (meaning that variable will contain whatever the end result was inside the function or a reference to it anyhow)

if (do_readfile_string(&$clicks,$filename)

 

the & means pass value by reference

if you change the $clicks in the function, the value that it gets from, will change

 

without &, if you change the value in the function, the value that it gets from will NOT change

ok that makes sense, thanks for the input  ;)

 

Does anyone know what could be wrong with this script?  It seems it is not incrementing the click count.  When I manually change the click value in the .txt file to say, 3, it gets overwritten with 1 after the link is clicked.  :confused:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.