Hello, I'm looking to create a disclaimer page as a precedent to viewing an exercise video. I'm currently using a standard text field (for initials) and check box (to agree). There's no problem with that.

I know I can just put the form submit to open a new page, but I don't want users to be able to share a link to a friend and have that friend not accept the disclaimer.

So let's say I have a 'exercise.php'. How would I make it so that the disclaimer form would display if a user visited the page and they would only be directed to my exercise video file after accepting the disclaimer?

Thanks for your help!

Member Avatar for diafol

session or cookie?

Hello

Sessions or cookies (specifically cookies) can work effectively for this problem.

Alternatively, you could store whether they have accepted into a database, via their IP or username..

It would be a session cookie. I don't have the knowledge (at least yet) to code a database for username.

Thanks for your help!

Member Avatar for diafol

You don't need to log the user in. You could work off anything you want:
In every page other than the disclaimer message page and any pages that require that you have read the disclaimer:

session_start();

In the disclaimer page:

session_start();
$_SESSION['dis'] = 1;

In all pages that require the disclaimer to be read:

session_start();
if(!isset($_SESSION['dis']))header("Location: read_disclaimer.php");

These bits of code should be placed at the top of the page, before anything else.

Should work. :)

I have my disclaimer as a html form.. do I need anything for a "form action=" or on submit?

Thanks!

Member Avatar for diafol

Just change the extension to .php

I have done this already, but should my form action say something particular?

<form action=" (what goes here) " method="post" onsubmit="return checkCheckBox(this)" name="waiver_form">
Member Avatar for diafol

No idea. I don't know what it's for.

I THINK (Don't blame me if I'm wrong -- Just a suggestion)

But you want it so that:

1. Checks to see if the disclaimer has been checked (This would auto be set to 0)
2. The user clicks on something like "accept" which then they submit a button
-- This would set the value to 1 and redirect the user to whatever page.

As Ardav rightly said, have a page that checks to see if the user has checked the disclaimer:

if(!isset($_SESSION['dis']))header("Location: read_disclaimer.php");

read_disclaimer.php
But, you need a way to to set it so something like:

<?php
     session_start();
     if(!isset($_POST['submitted']) && $_SESSION['dis'] != 1) // Check if form hasn't been submitted/session hasn't been set
     {
          echo '<form method="post" action="">';
		   // rest of the input boxes etc
		
			echo '<input type="submit" name="submit" value="Continue">';
			echo '<input type="hidden" name="submitted" value="TRUE">';
	  }else{
		
		// The form has been submitted.
		$_SESSION['dis'] = 1; // Set's the disclaimer to be 1
		header("Location: the_page.php"); // Redirect to whatever page you want
	}
?>

Does this make any sense? I may be wrong, just offering my opinion :)

The following is my form.. I have used the 'ardavs' information from above.. it works great to redirect to "disclaimer.php" during their session. Now I just need the following form to send them to 'lunges.php'.. I tried an "onclick" for the submit button, but it bipasses the javascript to make sure they checked the boxes and entered their initials.

Thanks for everyone's help until this point!

<form action="<?php echo $SERVER['SCRIPT_URL']?>" method="post" onsubmit="return checkCheckBox(this)" name="waiver_form">
          <p class="font24">
            <label>
            <textarea name="waiver" cols="100" rows="8" id="waiver" readonly>

HERE IS ALL THE WAIVER INFORMATION, YADA YADA...

</textarea>
            </label>
          <p class="font24"><span class="font14">I accept:</span> 
            <input type="checkbox" value="0" name="agree">          
            <span class="font14">Initials: 
            <label>
            <input name="initials" type="text" id="initials" size="4" maxlength="2" />
            </label>
            </span>
          <p class="font24">
                <input type="submit" name="send">
                <input type="button" value="Exit" onclick="document.location.href='index.php';">
            
           </form>
Member Avatar for diafol

The waiver is on the form that you're sending. So it's just a matter of clicking a checkbox right? No need for all the session stuff.

Have the submit button disabled on page load. Then when the checkbox is checked, enable it with js.

Sounds like a good idea, but I need the session to make sure they view it (disclaimer.php).. if I do the disable button, won't they be able to follow a link around the disclaimer (say if a friend shares the link)?

I can search the web for a disable submit button script, but would appreciate any help using it if you can... Can I do this with javascript to make sure they "Agree" to the waiver? Thanks Ardav!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.