Saturday, November 19, 2011

How to stop someone visitng my web page for certain peroid of time?

Dear friend, I am conducting a survey and I want to stop anyone taking survey again in 24 hours. For example, if I take survey today, it should stop me taking again in next 24 hours. It is a samll survey, so I will be going by participants’ full name. I am using PHP.


Any suggestion regarding this will be appreciated.


Thanks.

How to stop someone visitng my web page for certain peroid of time?
You will have an issue with ip addresses if you are targeting a certain area. For example AOL, EARTHLINK resuses IP address so you might block a new user from taking survey because IP was used by someone earlier. I believe use a database to store username(FIRST LAST NAME) and timestamp it, then if they enter the same username within the timeframe it will deny them access with outputs like the previous example... "You have taken this survey in the last 24 hrs." I do contract coding for small businesses, email me anytime.. lance@801promos.com
Reply:Use users ip address or host address and store it in database. Before allowing user to take a survey verify if this users ip is not in database or if its in database check if 24 hours time passed or not.








Here is the way to get users ip..





$IP = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"...


$proxy = $HTTP_SERVER_VARS["REMOTE_ADDR"];


$host = @gethostbyaddr($HTTP_SERVER_VARS["HTTP_X...





You'll get something that will look like this...





313.88.1.99 %26lt;--IP addy of user.


62.31.224.1 %26lt;--IP addy of server.


313-88-1-99.bas.cvx.blueyonder.com %26lt;-- Users host address.
Reply:Ok, take what the person above me did to get the ip address.


Now, use an if statement to direct them towards the right thing.


For example,





if ($ip == "$whatever") {


echo "





Sorry, you've already taken this. Wait 24 hours until next chance.





";}





or something like that.





Then, maybe something like this if you want:





if (!$ip == "$whatever") {


echo "





SURVEY HERE





";}





This is just to show you the idea, and if you have enough php knowledge, then you'll be able to modify it to fit the survey.


No comments:

Post a Comment