Learn how to a build a cloud-first strategyRegister Now

x
  • 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.


R.
0
roscoeh23
Asked:
roscoeh23
  • 2
1 Solution
 
rockymageeCommented:
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") {
    window.location="http://www.msn.com";
  }else{
    window.location="http://www.google.com";
  }
}
//--></script>

<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;
</form>
0
 
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:

<?php

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

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

?>
.... You can now put your html here ... Only users who have accepted the agreement will be able to see this page ...
0
 
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


0
 
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
http://ie.php.net/manual/en/reserved.variables.php
0

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