Forum Moderators: coopster

Message Too Old, No Replies

Redirection system

Checking cookie and redirect?

         

benoit

7:36 am on Jun 10, 2003 (gmt 0)

10+ Year Member



Hi all:
I have a php+mysql web system based.
Into my site i have some sections, downloads, forum....
The most part of people goes directly to downloads section
and after left the site.
My question is if any member go to download and don´t have posted into the forum it have a message (before download you need post), when member have posted i can go to downloads section and download any files.
The solution maybe can be a cookies system with .htaccess
or javascript, i don ´t know.
I´m not a programmer, sorry.
If anyone have some idea or can help me?
Thanks in advance.
Cheers

jatar_k

4:50 pm on Jun 10, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld benoit (or maybe Bienvenue is more appropriate)

I am assuming that you want to put this system in place to keep people from the download and run scenario.

Do you store anything in a database? How would you know if they had posted. I fyou store in a database you could just check to see if they had ever posted and then only show the content if $postcount > 1.

benoit

7:28 am on Jun 11, 2003 (gmt 0)

10+ Year Member



Hello:
I have a Mysql basedata, but i´m not programer.
So i don ´t know where i need insert the code.
If you want take a look at my site:
<snip>
Cheers

[edited by: jatar_k at 4:19 pm (utc) on June 11, 2003]
[edit reason] no urls thanks [/edit]

jatar_k

4:25 pm on Jun 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Well, I would say that you could do it on the download page itself.

Someone clicks on the download link
logged in?
no = dont show content or show login form
if yes
have they posted?
no = dont show content or show login form
yes = show downloads

As far as how/where all this data is stored you will have to familiarize yourself more with your system. Look at the mysql data to see what is available to use, maybe insert a new field. Then build the script on the actual download page. There are many more complex ways to do this but this would seem the most straightforward.

benoit

8:25 am on Jun 13, 2003 (gmt 0)

10+ Year Member



Hi jatar_k:
Thanks for your help and info, but if you can be more concrete, as you say i´m not much familiar with the code.
If you know some code to apply on download page,it would be been thankful.
Thanks

jatar_k

3:53 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



As far as how/where all this data is stored you will have to familiarize yourself more with your system

Thats the problem, I have no idea how your system works or what it stores or how it stores it. You would have to do a select from your database, based on the username stored in the session/cookie and see if they have any posts.

You would have to find out the name of the column and table that stores the post count. Once you have selected this data you can do something like this above the content.

if ($postcount > 1) {
//actual content here
} else {
//show "please post first" message
}
That code is simple. Here is a generic example of what the whole thing might look like. Fieldnames, tablenames, whether session or cookie for login you will have to figure out.

if (!isset($_SESSION['username'])) { 
//show the login script
} else {
$pquery = "select postcount from usertable where username='".$_SESSION['username']."'";
$postcountquery = mysql_query($pquery);
$postcount = mysql_fetch_field($postcountquery);
if ($postcount > 1) {
//actual content here
} else {
//show "please post first" message
}
}

All of the bold values can be searched on www.php.net for more information. This is a very generic example and must be customized to your system to work.

benoit

7:40 am on Jun 14, 2003 (gmt 0)

10+ Year Member



Hi jatar_K:
Thanks for your help i want try to apply your code.
Cheers