NameSilo

[PHP] Help with Script

Spaceship Spaceship
Watch

chronic

Established Member
Impact
1
Can anyone help me with this? I need to make a script which gives a user +1 click everytime someone clicks a personalized link. Also, I want the script to disallow the same IP to click it more than once within a 15 minute period.

I already have a login system made but I need to add the thing where it gives the link to you when you sign up. The only problem I am going to have it how to "give" the user +1 clicks and do the 15 minute period thing.

For the disallowing clicking within 15 minute period someone came up with the idea to get the time the link was clicked and then do olddate - currentdate = $x; then do $x >= 15 and then echo that they clicked the link and whatever else. Can someone maybe make a little script like that because I don't know how to retreive a time only date.

Also, for the +1 click, I was thinking of using Javascript but since I don't know that, I might have to use PHP. I was also thinking of how to do it; I came up with updating a mysql table everytime it was clicked but I am not sure about that. Any ideas on what I can do?

Sorry that I don't have anything to offer as my PayPal is empty and anything else I can give is too much.. So if any of you could be nice and help, that would be appreciated.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
As for time, what I would do is the following:

time() will get the time in seconds starting from the the Unix Epoch (January 1 1970 00:00:00 GMT). So, you could do something like the following:
Code:
$oldtime = $whatever_the_old_time_was;
$newtime = time();
if($newtime - $oldtime < 900) {
    // 900 Seconds = 15 Minutes
    dont_allow_the_click();
}

Reguarding the storing of the 15 mins thing. There's several ways of doing this. You could use cookies, sessions, or MySQL. Your best choice would be MySQL :imho: but if you don't have that resource available, I'd use cookies.
For MySQL, you could store the IP and time clicked in a table, and query the table every time, like below:
Code:
$ip = $_SERVER['remote_addr'];
$query = "SELECT * FROM `ip_table` WHERE ip=`" . $ip . "` LIMIT 0,1";
// connect to mysql here
$query_result = mysql_query($query);
$query_array = mysql_fetch_assoc($query_result);
$oldtime = $query_array['time'];
$newtime = time();
if($newtime - $oldtime < 900) {
    // 900 Seconds = 15 Minutes
    dont_allow_the_click();
} else {
    allow_the_click();
}

Catch my drift? If you need any help, throw some NP$ my way and I'll generously help you along with the script.

Oops! Read your post and saw that you don't have anything... well I'll be nice, if you need help just PM me :). Just leave me some rep if you do.
 
0
•••
Okay, thanks for all your help. I got some help on SitePoint already but you still helped me with a few things.
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back