Limit user to clicking only one link on a page

Links for php scripts

Moderators: macek, egami, gesf

Post Reply
FishBird
New php-forum User
New php-forum User
Posts: 21
Joined: Thu Apr 12, 2012 8:05 am
Contact:

Re: Limit user to clicking only one link on a page

Post by FishBird » Thu Apr 12, 2012 10:23 am

A very simple solution will be a session check:

video1 5 minutes:

$_SESSION['wait'] = strtotime("+ 5 minutes");

check on video2:

if( @$_SESSION['wait'] > time() ) exit("You must wait ".($_SESSION['wait'] - time())." seconds");

FishBird
New php-forum User
New php-forum User
Posts: 21
Joined: Thu Apr 12, 2012 8:05 am
Contact:

Re: Limit user to clicking only one link on a page

Post by FishBird » Thu Apr 12, 2012 11:16 am

Why whould you want users to only be able to see only one youtube video?

I dont see any php code in your scripts, so what do you have?...

sessions wont work for a whole day, and you can easily delete your cookies and the limitation is gone.

You should store the ipaddress of the user in a sql table, or let them login. Check if they visited before this day, and if they have dont show the video.

I am not going to build a copy and paste script for you. With this information you can make it yourself, or hire someone to do it.

FishBird
New php-forum User
New php-forum User
Posts: 21
Joined: Thu Apr 12, 2012 8:05 am
Contact:

Re: Limit user to clicking only one link on a page

Post by FishBird » Thu Apr 12, 2012 11:45 am

Allright, here is a very simple solution. Only lasts while the session is active (usually untill the user closes the browser):

Code: Select all

<?php

session_start()

$viewed = isset( $_SESSION['viewed'] ) ? true : false;

if( $viewed ===true ){
?>

You have already watched today

<?php
exit;
}
$_SESSION['viewed'] = true;
?>
<html>
<body>
You can watch one video today.  Please choose only one:
<br><br><br>
Option 1:
<a href="location1.php">link 1</a><br><br>
Option 2:
<a href="location2.php">link 2</a><br><br>
Option 3:
<a href="location3.php">link 3</a><br><br>
Option 4:
<a href="location4.php">link 4</a><br><br>
</body>
</html>

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests