Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

accpept/decline chekboxes redirect.

I want to have 2 checkboxs where the user either accepts or declines the disclaimer. The checkboxed need to redirect automatically when they are clicked to the homepage if they decline and the main bit of the website if they decline.

  • 2
1 Solution
you could just make 2 links if all you are doing is redirecting:

<a href="homepage.htm">Accept</a>&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="mainbit.htm">Decline</a>

With javascript:

<script language="JavaScript"><!--
function redirect(decision) {
  if (decision == "accept") {

<form name="redirectForm">
<input type="checkbox" onClick="redirect('accept');"> Accept&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="checkbox" onClick="redirect('decline');"> Decline&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Julian MatzCommented:
Or you could use a server side language like PHP, that way you can be sure that no one accesses the page without having accepted the aggreement...

The PHP page takes the form data and processes it:


$accept = isset($_POST['accept']) ? $_POST['accept'] : '';

if (empty($accept))  {
 header ('Location: aggreement.html');
} elseif ($accept != 1) {
 header ('Location: rejected.html');

.... You can now put your html here ... Only users who have accepted the agreement will be able to see this page ...
roscoeh23Author Commented:
Nice Work!

By the way the php version does not work as when you set the variable with

$accept = isset($_POST['accept']) ? $_POST['accept'] : '';

It is automatically set to empty and redirects to agreement.html

Julian MatzCommented:
Yes, I know. That was the point. It will not be empty however if you post a variable called 'accept':

<input type="radio" id="accept" name="accept" value="1" /> <label for="accept">I accept</label>

It could also be that you have an older version of PHP, in which case you could use:

$HTTP_POST_VARS instead of $_POST

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now