When I was recently showing the Booking System to a customer they asked about a really handy feature. The feature request was for the ability for them to set a Sites Terms and Conditions and then have customers agree to this before it will allow them to use the site. What a great idea. So now it was time to put it into action and add the functionality to the site.

After working through it I have decided that it will need to do the following

  • The site will need to record when the terms and conditions where accepted and what they were (In case they change)
  • It will need to be able to be reset by the site admin’s in case of a change. (or per user basis)
  • It needs to be disruptive if they are not agreed to.

So with that in mind here is how I went about implementing it.

Database Changes

First up is some changes to the database. As this is a per user item there are a few additional Columns that will need to be added to the users table. The columns will be

  • accepted_terms – This is a copy of the terms that the user agreed to. This way the site terms can change, but the terms that were agreed to are able to be referenced.
  • terms_accepted – This is a true/false field that is either true the T&C’s have been accepted or false, they haven’t
  • accepted_date – Date that the terms were accepted in case they are required.

Here is the SQL

Site Settings.

Next step was to create site setting that holds the terms and conditions. Site settings are easily added in the booking system by adding a entry to the database with the name as the key and the terms and conditions as the value. (Think of the settings as a huge array). Once that part is created I added the ability to edit it to the Site Settings page.

Site Changes.

The last thing to do was to make it disruptive to users that had not agreed to them. On the main menu page I added the following code to display a simple table if the terms_accepted value in the database was false.

And here is the code that checks and updates the database (submitpage.php)

Now I know this doesnt completely block the user from the site, it does however make it difficult to navigate unless they are accepted as every time they hit the main menu (Which is often) they would be presented with the Terms and Conditions Acceptance.