How do I make links clickable only to subscribed members?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dgriff
Forum Newbie
Posts: 3
Joined: Tue Jul 06, 2010 4:50 am

How do I make links clickable only to subscribed members?

Post 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
User avatar
rolanddev
Forum Newbie
Posts: 9
Joined: Mon Jul 05, 2010 12:28 pm
Location: Bucharest

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

Post 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.
Post Reply