Page 1 of 1

How do I make links clickable only to subscribed members?

Posted: Tue Jul 06, 2010 5:07 am
by Dgriff
I want to place a table of 20 video tutorial links on my index.php page. I have an os commerce site. The first 3 videos can be viewed by anyone but only subscribed members can click on and view (in a pop up window) the remaining 17 videos. I still want non subscribers to be able to see the list of videos (just not able to click on and view). How do I set this up? Thanks

Re: How do I make links clickable only to subscribed members

Posted: Tue Jul 06, 2010 5:30 am
by rolanddev
By subscribed, you mean registered, don't you?

If yes, then you can make this thing:
a) Create a register page
b) Use the session or cookies method to authenticate the members, in this case I will show you the cookies method.
c) In the movies Browse page write the following php code for every "Only registered Video":


//check if the user is logged in

Code: Select all

<?php
/*...........................................................OTHER CODE........................................................................*/
$logged=mysql_num_rows(mysql_query(Select * FROM users where username=$_COOKIE[username] and password=$_COOKIE[password])); //count the rows
If ($logged < 1)  //he is not logged in so...
$registered=0;
else  //is registered and logged in
$registered=1;
$link = "http://mywebsite.com/videos/secretcode/video4.html";                    //the link to the forth video
If ($registered = 1) 
print $link;                                                                                                   // $link is the link for the pop up window declared above
else
print "<a href=login.php>LOG IN TO WATCH THIS VIDEO</a>";
?>
I hope I was helpful, for details, ask me and I will reply!
Untested code.