# How to create simple privacy policy checkbox



## howard.a.s (Jul 22, 2005)

I would like to create and place a checkbox on my w/s privacy policy page.

The checkbox could either be unchecked, requiring the visitor to check it before being able to proceed, and in doing so agreeing to the privacy policy, or prechecked, meaning they would need to uncheck it if the do not agree to the privacy policy.

If they agree to the privacy policy they'll gain access to the website, but if they do not agree they will receive a 
windows alert box (similar to the one shown in this example when you hit the 'try it now' button: http://www.javascripter.net/faq/alert.htm) advising them to make their decision.

Can anyone help me out with any code that will fulfil these requirements, together with simple details of how to include it into my page.

Also, how would I be able to receive the form data, to let me know if they have accepted/not accepted, and is this absolutely necessary? Could the info be emailed to me?

Any advice gratefully received.


----------



## dukevyner (Nov 4, 2011)

something like this? http://channeljackers.co.cc/boxtest.html


> \


 obviously, after they submit the form you would set a cookie to say that the have agreed... its hard to answer the rest of your question... so lets finish with a few questions... why do you want to know?... wouldn't a cookie on those who accept (as i assume this has something to do with cookie laws) and the lack there of on users who didn't accept be enough? why would you want to email it? what exactly do you want emailed? an ip address?... what is the goal of gathering the form data?... do you want only those who accepted the policy to be able to view it?


----------



## howard.a.s (Jul 22, 2005)

Thanks for the reply. The code you supply certainly looks like it will do the job. As for your other questions, I guess my original post did ramble on quite a bit, mainly because I am not certain of how all this works myself, so it was quite tricky for me to explain how I imagined this should work. I guess I just thought that when the visitor ticks 'yes' to accept that they have read (or at least say they have read) the privacy page, then I would need to record this preference as proof of their acceptance - although without any other details being submitted by the visitor, such as name, address, email etc, as might be the case with some forms, then there probably wouldn't be any point in doing this. 

When it comes to setting a cookie to say they have agreed, I have no understanding of how this is achieved - by which I mean how the cookie is generated, whether it is stored on their computer, or on the server that hosts my website, or in a database? 

How do I get the cookie generated when they select 'yes'. Please can you explain?

Also, how can I tweek the code you have supplied so that when they accept they are re-directed to the index page of my site, and if they decline they are re-directed to, for example, Google?

Any further advice gratefully received.


----------



## dukevyner (Nov 4, 2011)

howard.a.s said:


> Thanks for the reply. The code you supply certainly looks like it will do the job. As for your other questions, I guess my original post did ramble on quite a bit, mainly because I am not certain of how all this works myself, so it was quite tricky for me to explain how I imagined this should work. I guess I just thought that when the visitor ticks 'yes' to accept that they have read (or at least say they have read) the privacy page, then I would need to record this preference as proof of their acceptance - although without any other details being submitted by the visitor, such as name, address, email etc, as might be the case with some forms, then there probably wouldn't be any point in doing this.
> 
> When it comes to setting a cookie to say they have agreed, I have no understanding of how this is achieved - by which I mean how the cookie is generated, whether it is stored on their computer, or on the server that hosts my website, or in a database?
> 
> ...


The problem is with out recording a name or email... the're is really no point... the only thing that you could do... is add a record to a database... the problem is the only thing you would have is their ip address, which for most is dynamic... meaning that their ISP changes it, every so often.

What you could do is (assuming people aren't allowed to view the site with out accepting the terms) set the cookie that says they have agreed, on every page in your site insert a php script... or some javascript code to check for the cookie, if the cookie doesn't exist, redirect them to your policy page... I under stand that you don't understand how to do most of this, thats fine you can look it up, and i will write some pages, and do my best to explain it in the code... i will post back when i'm done


----------



## howard.a.s (Jul 22, 2005)

Hello again. Apologies for the delay in reply, but I suppose it's mainly due to the time difference between your geographical location and mine. Thanks for the info and I shall wait for your next post with interest.


----------



## dukevyner (Nov 4, 2011)

here is the new code for the same file


> <?php if($_POST['submit']){
> $cook='tyes';
> setcookie("term_yes",$cook, time()+3600*24*365);
> $subject = "Terms Acceptance";
> ...


 this file will now set a cookie, and email you the ip address of any one who accepts

below is used to send anyone who has not accepted the terms to your policy page. but in order for this to work all pages would have to be changed to php and include the code


> <?php if($_COOKIE['term_yes'] !='tyes'){echo'';}?>


 you may need to change 'policy.html' to what ever your policy file is called


----------



## howard.a.s (Jul 22, 2005)

Very many thanks for investing some of your time in helping me with this matter. I am genuinely grateful. 

I've had a look at the code you've posted and I think it makes sense to me, but I'm going to have a further look and then post back here with any questions, which I am certain there are bound to be, before I even attempt to get this integrated into my page.

Please watch this space, as they say.......


----------



## howard.a.s (Jul 22, 2005)

Okay, so I have copied and pasted the code you posted into my w/s privacy policy page, set the 'to and from' email addresses and also the url for re-direct upon acceptance of terms. I saved this page with the .php extension and uploaded to my test folder. All works perfectly and I successfully receive an email each time the submit button is clicked. As for the line of code used to contact me if they do not accept the terms, I could include this, but where would I place this additional line in the existing code?


----------



## dukevyner (Nov 4, 2011)

howard.a.s said:


> Okay, so I have copied and pasted the code you posted into my w/s privacy policy page, set the 'to and from' email addresses and also the url for re-direct upon acceptance of terms. I saved this page with the .php extension and uploaded to my test folder. All works perfectly and I successfully receive an email each time the submit button is clicked. As for the line of code used to contact me if they do not accept the terms, I could include this, but where would I place this additional line in the existing code?


Well at the moment you have to accept... The check box does not un check


----------



## dukevyner (Nov 4, 2011)

If you want the user to be allowed to view the site with out accepting... then first DO NOT include this php code on any pages


> <?php if($_COOKIE['term_yes'] !='tyes'){echo'';}?>


make some changes to the policy page form (add what is in GREEN and remove what is in RED)


> *Privicy policy*
> 
> " method="post">
> 
> ...


 and replace the php code in the policy page with this


> <?php if($_POST['submit']){ if ($_POST['box']=='accept'){
> $subject = "Terms Acceptance";
> $today = date("D M j Y g:i:s a T");
> $ip=$_SERVER['REMOTE_ADDR'];
> ...


*AGAIN:* This is *ONLY* if the user should be allowed to view the site without accepting, if they should *not *be allowed to view without accepting *IGNORE THIS POST*


----------



## howard.a.s (Jul 22, 2005)

Thanks for the new code and for the very thorough explanation. As I think I mentioned previously, I have managed to successfully get the initial code you posted integrated into my page and working correctly. I am going to have a play around with this new code too, by creating a backup copy (or two) of my page and then seeing which best suits my purpose.

Thank you again and I will post back to this thread in a day or two with an update once I have had a chance to try this out.


----------



## Kanden (May 22, 2012)

Try using a simple pre-coded form like a google gadget.


----------



## howard.a.s (Jul 22, 2005)

Hi dukevyner (Luke). I promised to post back as and when I had experimented further with the code you created for me. After some thought, I have decided to stick with the first version of the code, whereby the check box is ticked by default and the visitor can continue to browse without accepting. This system works best for me, given the way in which it will be included in my site. I will keep all of the additional code you have posted just in case I decide to change my mind at some point! In the meantime, and once my site is completed (which I hope will be very soon) I will post back to this thread with a link to the completed and working page which includes the code you have provided. Very many thanks for all your input, which is gratefully received. I now have just one further matter to sort out, relating to the inclusion and display of rss news feeds on one of the pages of my web site, and I am now going to post a new thread in this catagory for help. Perhaps you might be able to offer some advice on this matter also?


----------

