View Full Version : Greying out a link
_SKiLLz_
08-28-2004, 06:08 AM
Hi
I have virtually no php knowledge what so ever but i am looking into doing the following.
I would like to make a link, which takes u to a new page, and then after that link has been clicked, it greys out and cant be used again for a set amount of time.
eg: Someone clicks the link, and then they cant click it again for 24 hours. Maybe using cookies? :S
How can i go about this since i have no idea?
Please help.
thanks
wiffles
08-28-2004, 08:15 AM
Cookies are one way to do it.
Take a look at http://www.php.net/manual/en/features.cookies.php
Place a cookie that would disable the link if it existed (if it did, you would echo a greyed-out link substitute instead of the link itself). Of course, anyone could delete the cookie so doing it serverside is more secure but a bit harder to set up.
_SKiLLz_
08-29-2004, 07:30 AM
This is going to be difficult and cookies wont work, I forgot that users can easily delete them lol.
Can anyone else help me with my idea.
thanks
andrews_john
08-30-2004, 01:56 AM
you may make a special files - with an IP adress and time of restoring of link... on clicking you should find neccesary file (with the same IP) and comapre time of clicking and time from file - if 1st is less than 2nd - then link should be disabled...
BUT. it would work only for static IPs ...
DA Master
08-30-2004, 05:07 AM
Quote: doing it serverside is more secure but a bit harder to set up.
Really, your best way to do this is with sessions, they are basically cookies held on the server so that the client cannot change them...
http://uk.php.net/session
_SKiLLz_
08-30-2004, 05:09 AM
Thanks.
It looks difficult and i dont have any php knowledge what so ever so i think im going to have to leave it :(
DA Master
08-30-2004, 05:13 AM
Here you are...
<?php
//start the session
session_start();
//register variables
$_SESSION['is_clicked'] = false;
//check for status of session cookie
if($_SESSION['is_clicked'] == true)
{
echo "Click Here";
} else {
echo "<a href=\"link.php\">Click Here</a>";
$_SESSION['is_clicked'] = true;
}
?>
You must have session_start() at the very top of your page or this will not work.
_SKiLLz_
08-30-2004, 05:14 AM
Thankyou very much!
But i didnt understand the last part, about adding sessionstart at the top of my page, what do i do?
thanks again :)
DA Master
08-30-2004, 05:18 AM
Like this...
<?php session_start(); ?>
<html>
<head>
<title>Your Title</title>
</head>
<body>
<!-- CONTENT -->
</body>
</html>
_SKiLLz_
08-30-2004, 05:24 AM
Well i tried it but it came up with several errors so i think im just going to leave it.
Here is the file that I was planning on adding it to. It would go beneath the bullet point links that you see in it.
DA Master
08-31-2004, 03:44 AM
Not been funny but you do have it named as .php dont you?
_SKiLLz_
08-31-2004, 06:31 AM
Yes.. Obviously
DA Master
08-31-2004, 06:37 AM
Well what were the errors?
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.