Ideas anyone! Link or click validation
Moderator: General Moderators
Ideas anyone! Link or click validation
Hello,
I have a free app that I want to distribute on my website but in exchange I would like the potential downloader to view 3 randomly generated webpages before they would get to the download link. All they need to do is view the pages and once validated they would get the link to the download.
So eg.
I would have 3 links to pages that would open in a new tab or window. once they have viewed that page when they come back they would need to click on link #2 and then 3.
I need to figure out some code that would validate that the link was clicked and then move on to the next.
Or ideas similar to what I need would be great as well.
thanks in advance
I have a free app that I want to distribute on my website but in exchange I would like the potential downloader to view 3 randomly generated webpages before they would get to the download link. All they need to do is view the pages and once validated they would get the link to the download.
So eg.
I would have 3 links to pages that would open in a new tab or window. once they have viewed that page when they come back they would need to click on link #2 and then 3.
I need to figure out some code that would validate that the link was clicked and then move on to the next.
Or ideas similar to what I need would be great as well.
thanks in advance
Re: Ideas anyone! Link or click validation
The easiest way would be to set a SESSION or COOKIE each time a page is viewed. So at the top of each page have:
Then to check if they have all been visited:
Code: Select all
$_SESSION['page1'] = "yes";
Code: Select all
if(isset($_SESSION['page1']) && isset($_SESSION['page2']) && isset($_SESSION['page3']) {
//Output download link here
}
Re: Ideas anyone! Link or click validation
I like the idea of using the session as opposed to the cookies as some users will have cookies turned off.
I know a bit of php but have not used sessions at all before.
I use the include alot to allow myself to change certain things without having to change them on each page.
I have done some reading about sessions but am still getting a parse error on the line that checks if they have all been visited.
Do you mind going into detail more about where the lines need to be placed and on what pages?
I have added this to the top of 3 pages that I will start with as the 3 links.
Page 1
<?php
session_name ('visitor');
ini_set("session.use_cookies',0); // Don't use cookies
session_start()
$_SESSION['page1'] = "yes";
?>
Page 2
<?php
session_name ('visitor');
ini_set("session.use_cookies',0); // Don't use cookies
session_start()
$_SESSION['page2'] = "yes";
?>
Page 3
<?php
session_name ('visitor');
ini_set("session.use_cookies',0); // Don't use cookies
session_start()
$_SESSION['page3'] = "yes";
?>
I added the line that checks to see if they have been visited to the main page where all 3 links are placed.
<?php
session_name ('visitor');
session_start();
if(isset($_SESSION['page1']) && isset($_SESSION['page2']) && isset($_SESSION['page3']) {
<a href="my file">Download</a>
}
Of course "my file" would be replaced with the download link.
the session_name and session_start was me trying to figure it out after getting the error.
It says parse error on line 4 which would be the if statement.
I am probably way off but a few more minutes of your time could push me in the right direction.
Thank again for your quick response.
I know a bit of php but have not used sessions at all before.
I use the include alot to allow myself to change certain things without having to change them on each page.
I have done some reading about sessions but am still getting a parse error on the line that checks if they have all been visited.
Do you mind going into detail more about where the lines need to be placed and on what pages?
I have added this to the top of 3 pages that I will start with as the 3 links.
Page 1
<?php
session_name ('visitor');
ini_set("session.use_cookies',0); // Don't use cookies
session_start()
$_SESSION['page1'] = "yes";
?>
Page 2
<?php
session_name ('visitor');
ini_set("session.use_cookies',0); // Don't use cookies
session_start()
$_SESSION['page2'] = "yes";
?>
Page 3
<?php
session_name ('visitor');
ini_set("session.use_cookies',0); // Don't use cookies
session_start()
$_SESSION['page3'] = "yes";
?>
I added the line that checks to see if they have been visited to the main page where all 3 links are placed.
<?php
session_name ('visitor');
session_start();
if(isset($_SESSION['page1']) && isset($_SESSION['page2']) && isset($_SESSION['page3']) {
<a href="my file">Download</a>
}
Of course "my file" would be replaced with the download link.
the session_name and session_start was me trying to figure it out after getting the error.
It says parse error on line 4 which would be the if statement.
I am probably way off but a few more minutes of your time could push me in the right direction.
Thank again for your quick response.
Re: Ideas anyone! Link or click validation
Ok I have fixed all of the errors. Some of you might have noticed in the previous post a few brackets missing and such.
I was also getting an error with the line.
$_SESSION['page3'] = "yes";
I changed to
$_SESSION['page3'] = 'yes';
and error went away.
But I'll move on to my current issue:
After clicking on all 3 links, The else statement still holds true for some reason. I am not sure why its not validating.
Here's the code that is placed on the 3 pages I am linking to.
I was also getting an error with the line.
$_SESSION['page3'] = "yes";
I changed to
$_SESSION['page3'] = 'yes';
and error went away.
But I'll move on to my current issue:
After clicking on all 3 links, The else statement still holds true for some reason. I am not sure why its not validating.
Code: Select all
<?php
if (isset($_SESSION['page1']) && isset($_SESSION['page2']) && isset($_SESSION['page3'])) {
echo'<a href="my file">Download</a>';
}
else
{
echo 'You have not looked at all 3 pages yet';
}
?>Here's the code that is placed on the 3 pages I am linking to.
Code: Select all
<?php
session_name ('visitor');
ini_set('session.use_cookies',0); // Don't use cookies
session_start();
$_SESSION['page3'] = 'yes';
?>- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Ideas anyone! Link or click validation
You need to refresh the page to update the session info. Have them click a reload link after they've view the other pages.
Re: Ideas anyone! Link or click validation
Tried that without success.
I'm making an error somewhere else.
I'm making an error somewhere else.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Ideas anyone! Link or click validation
What does the error say?
Re: Ideas anyone! Link or click validation
Thats the thing, I'm not getting any more errors, It's just skipping the download link and still displays what happens in the else part of the statement.
After clicking on the 3 links I thought it would pass that validation and show the download link, or link to the download page.
Any ideas on what i should check?
I think there's possibly something wrong with my server logging the session.
After clicking on the 3 links I thought it would pass that validation and show the download link, or link to the download page.
Any ideas on what i should check?
I think there's possibly something wrong with my server logging the session.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Ideas anyone! Link or click validation
Change
In each page to
And change
To
Code: Select all
$_SESSION['page1'] = "yes";Code: Select all
$_SESSION['page_count'] += 1;Code: Select all
if(isset($_SESSION['page1']) && isset($_SESSION['page2']) && isset($_SESSION['page3']) {Code: Select all
if(isset($_SESSION['page_count']) >= 3) {Re: Ideas anyone! Link or click validation
I made the changes and still the validation doesn't pass.
then I searched the web for some quick answers and decided to try changing the session_start() to the second line and its now working.
thanks to both of you for your assistance.
It is greatly appreciated
then I searched the web for some quick answers and decided to try changing the session_start() to the second line and its now working.
thanks to both of you for your assistance.
It is greatly appreciated