A simple solution might look like:
PHP Code:
<?php
ob_start();
header('Content-Type: text/html; charset=iso-8859-1');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en" dir="ltr">
<head>
<?php
if(!isset($_GET['forum'])) {
?>
<link rel="stylesheet" type="text/css" href="terms.css">
<title>MyForum — Terms & Conditions Agreement</title>
</head>
<body>
<form action="?forum" method="post">
<fieldset><legend>Terms and Conditions</legend>
<div id="terms">
<!-- Mark-up terms and conditions normally (as
paragraphs, headings, lists, etc.), here.
-->
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.</p>
<p>Nulla vel tortor sit amet pede imperdiet varius. Nullam fringilla
consectetuer lorem. Curabitur iaculis lectus non diam. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin
libero lacus, vestibulum tincidunt, tincidunt non, condimentum sed,
libero. Ut tempor, lacus sit amet elementum aliquet, quam risus euismod
wisi, ac varius purus lacus vitae nibh. Nulla fermentum velit et nulla.
Cras non wisi ac libero posuere mattis. Nam condimentum consequat augue.
Quisque faucibus pede vitae lectus. Duis blandit ipsum vitae nibh cursus
lobortis.</p>
<p>Phasellus in ante. Donec viverra luctus lectus. Integer laoreet
pellentesque massa. Suspendisse vestibulum elementum tortor. Etiam eu
sapien. Phasellus rutrum, tellus nec rhoncus faucibus, lorem augue
tristique wisi, et mattis ipsum neque quis mi. Pellentesque tincidunt
mollis nunc. Donec et elit eget ante pellentesque viverra. Sed libero
erat, dictum at, commodo ac, tristique sed, turpis. Vivamus molestie
tortor. Suspendisse potenti. Class aptent taciti sociosqu ad litora
torquent per conubia nostra, per inceptos hymenaeos. Suspendisse pharetra
mattis nibh. Curabitur dolor sem, vestibulum id, varius at, nonummy ac,
nisl. Pellentesque eleifend magna quis ipsum. Nam malesuada, odio eu
congue vehicula, quam dolor tempus wisi, in interdum neque risus eu
augue. Nam eu wisi. Cras dapibus.</p>
</div>
<label><input name="accept" type="checkbox" value="true"> I agree to the
above terms and conditions.</label>
<p>If you do not agree to the terms and conditions, you will not be able to
enter this forum.</p>
<input id="submit" type="submit" value="Continue">
</fieldset>
</form>
<?php
} else if(isset($_POST['accept']) && ('true' == $_POST['accept'])) {
?>
<link rel="stylesheet" type="text/css" href="forum.css">
<title>MyForum — Home</title>
</head>
<body>
<!-- Forum contents -->
<?php
} else {
?>
<title>Back 'o Beyond</title>
</head>
<body>
<!-- You need to decide what to do here. -->
<?php
}
?>
</body>
</html>
<?php
header('Content-Length: ' . ((string) ob_get_length()));
ob_end_flush();
?>
If you look closely, you'll see PHP if..else statements dispersed amongst the HTML. Instead of including markup within those statements directly (as I have, above), you could use the include or require construct to insert the contents of another file. This means you don't have to maintain a huge, monolithic PHP file.
You should also see, near the end, a comment that reads: "You need to decide what to do here." If the code reaches that branch, the user submitted the form but didn't agree to the conditions. There are two choices for you here. The first is that you present some HTML to the user, perhaps to explain what happened, and why. The second is to redirect the user somewhere - either another site or elsewhere in the current one.
I should point out that the agreement you present with this particular code may not be considered binding. If a user knows of a URL beyond this check, they can go there directly and they might not be considered, legally, to have given their consent and understanding to your terms. If, for some reason, you might need legal backing, a more complex arrangement would be necessary. If not, then this should be sufficient.
Mike
Bookmarks