Jump to content

Recommended Posts

I am trying to make a site similar http://www.ihatesara.com/ where each unique visitor gets a referrer link and once they get X amount of people to visit that link than the first user will get a locked link to unlock.

 

I don't know how I would do that and I was wondering if this forum could help me.

Link to comment
https://forums.phpfreaks.com/topic/197397-unlock-link-after-5-refers/
Share on other sites

well for each user in your table, you could just have a counter to keep track of how many referels there have been. In your referal link, you would put an id or something unique to each row, and update the table with a query like

$id = $_GET['id'];
$sql = "UPDATE table set referals = referals + 1 where id = $id";
....

 

 

then you could do something like

//get id from database with query
$num = $row['referals'];//get number of referals from table row array
if ($num > 5){
//show some pic
}
if ($num > 10){
//show another pic
}
//etc

 

Well, you can add a column to the table that references your link ID numbers or what ever they are. And just start the count at 0, and every time someone visits a link that is recognized in the DB you can have it find what the current count is and then have it add to it.

 

Although issue with that is someone only need click the link 5 times and it just adds every time. But thats the simplest route.

 

Next simple route would be similar in concept but rather add a column you make a whole new table one that adds a time stamp, visitor ip, the referenced link id. You then have the script INSERT a new row every time. someone visits the link. You have the script check the link so to speak, you gather the IP of the visitor if the IP is found in refrence to the link code then you ignore it tell them they have already been counted, you can also use the time stamp to just block more than one click per day per ip per link code (or all of them). There is a lot of x factors, how do you want it to run, what do you want it to do etc, I know you said like that other site, but it boils down to what you want to do.

 

Then im sure theres 101 ways to make it even more complicated and more protective. but I could right a book here of different concepts, ideas, possibilities, etc if i go into it

Good concept on mikesta707's part, but based on that alone its pokes at what I just said with the simplest idea of it, in the case of mikesta707's rendition the user that gets the link only need click on it themselves 5+ times to achieve desired goal, I am assuming your wanting to have it referal based so that wouldn't work well for you.

 

mikesta707's offering is an excellent start point however.

well for each user in your table, you could just have a counter to keep track of how many referels there have been. In your referal link, you would put an id or something unique to each row, and update the table with a query like

$id = $_GET['id'];
$sql = "UPDATE table set referals = referals + 1 where id = $id";
....

 

 

then you could do something like

//get id from database with query
$num = $row['referals'];//get number of referals from table row array
if ($num > 5){
//show some pic
}
if ($num > 10){
//show another pic
}
//etc

 

I am not that good with PHP thats why I joined, They would not be signed up. I wanted the db to save their IP address and work off like that. Do You think you could put that in a file? or is that too much to ask

well in that case you could store referal ids/links in relation to someone's IP address rather than the conventional user name and password combination. You could store the stuff in a file, but using a database would be far easier to manage/maintain, and add more code on top of.

 

as monkeytooth said, my example was just a starting point though, as there are quite a few things to consider. I would suggest starting with a simple table that stores IP address, the referal link code (which you can generate how ever you how, however, I would suggest hashing the IP address, via md5 or another hashing algorithm, or something, as thats probably the simplest way to do it), and number of referals and try to get the referals counter working. after that you can worry about the more complex problems like repeated link clicking. For this problem, monkeytooth's solution would probably work rather nicely and simply

well in that case you could store referal ids/links in relation to someone's IP address rather than the conventional user name and password combination. You could store the stuff in a file, but using a database would be far easier to manage/maintain, and add more code on top of.

 

as monkeytooth said, my example was just a starting point though, as there are quite a few things to consider. I would suggest starting with a simple table that stores IP address, the referal link code (which you can generate how ever you how, however, I would suggest hashing the IP address, via md5 or another hashing algorithm, or something, as thats probably the simplest way to do it), and number of referals and try to get the referals counter working. after that you can worry about the more complex problems like repeated link clicking. For this problem, monkeytooth's solution would probably work rather nicely and simply

I know I am saying I have no idea what to do with that code. Im a noob

well then I would start with a tutorial on the $_GET array. here's a good one then start learning about SQL and using it with your database. The most common database I see used around here is MySQL (good starter tutorial) and after that it should be pretty straight forward

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.