user3026021
user3026021

Reputation: 3

I would like to only be able to access a page through a link on my site

I have a store on my website, and I need to make it so that before a user is able to actually buy things, they have to agree to the terms and conditions. Right now, you can click agree to get to the page, but you can bypass the agree page by going to the index : http://mafiateam7.com/ and clicking on donations.html. I would like to make it so that the ONLY possible way for anyone to reach the store page is to click agree.

I have minimal coding experience, so specificity would be very helpful.

Justin

Upvotes: 0

Views: 437

Answers (2)

James M. Lay
James M. Lay

Reputation: 2470

Maybe try putting this snippet anywhere in your DONATIONS.HTML file.

<script type="text/javascript">
if ( document.referrer != "http://mafiateam7.com/store/" ) {
    window.location = "http://mafiateam7.com/store/"
}
</script>

It should redirect the user to the user agreement, but only if they did not come from there.

Explanation: document.referrer will allow you to tell which base-uri the client came from, but there's a couple gotchas:

A. This code is implemented in javascript, which isn't supported by all browsers. That being said, even dated versions of Firefox, IE, Chrome, and Opera all support javascript by default. If you implement the equivalent code on the server side, then javascript support isn't an issue.

B. Whether you implement this on the server side or client side, this technique is not secure because the http referrer headers can easily be manipulated, but hopefully this is good enough for what you are trying to accomplish!


Good luck :-)

Upvotes: 2

tinthetub
tinthetub

Reputation: 2196

Looks like you'll need to learn PHP. And that is assuming that you have prior knowledge to some basic HTML and CSS. PHP is hidden when viewing a page's source because it's basically what holds everything together and stores valuable information (passwords, private info). PHP is used for creating login/registration pages, storing data and etc... In your case, PHP would be used to hide the destination URL and "force" the user to accept the terms before proceeding. The same technique is used in Social Networks and Forums during the account registration process. To get you started: http://www.w3schools.com/php/

Upvotes: 0

Related Questions