Russia Posted October 18, 2009 Share Posted October 18, 2009 Hello. I am wondering how to make a accept terms of agreement button. Like there will be a paragraph with the terms and then a button that says 'I agree' or 'I do not agree'. I want the Agree button to go to the next page, but the next page cannot be visited by itself unless you accept and read the terms from the first page. Can someone give me a script to do that? I have looked around but most of them are like a pop up for when a check box is missing. Quote Link to comment Share on other sites More sharing options...
Maq Posted October 18, 2009 Share Posted October 18, 2009 You should check it server side and client side. To avoid submitting to the next page, just submit the page to itself. With javascript you can utilize onSubmit and inject some HTML in the page if the checkbox isn't checked. Quote Link to comment Share on other sites More sharing options...
Russia Posted October 18, 2009 Author Share Posted October 18, 2009 I do not understand. This is what I got so far: <input type = "button" id = "but1" value = "I DO accept the terms and conditions" onclick = "redirect()"> <input type = "button" id = "but2" value = "I DO NOT accept the terms and conditions" onclick = "cancel()"> <script type = "text/javascript"> function redirect() { window.location = "page2.html"; } function cancel() { window.location = "http://google.com"; } </script> Wouldn't I need to make this into a form? and check if the button what selected? I have no idea how to. If you can help me out would be great. Quote Link to comment Share on other sites More sharing options...
haku Posted October 18, 2009 Share Posted October 18, 2009 We help people with code they are writing here, or help them with minor changes to code they have. But if you are looking for someone to write code for you, you should try the freelance section of the site. Quote Link to comment Share on other sites More sharing options...
Maq Posted October 18, 2009 Share Posted October 18, 2009 Wouldn't I need to make this into a form? and check if the button what selected? Yes. There is a JS function called onSubmit, where you can invoke a function to check your input values and handle your form validation/errors. ie: </pre> <form action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>" id="blah" name="blah" onsubmit="return validateData()">< Quote Link to comment Share on other sites More sharing options...
Russia Posted October 18, 2009 Author Share Posted October 18, 2009 Okay I came up with these 2 things, if(isset($_POST['checkBoxName']) && $_POST['checkBoxName']=="checked")) [\php] or maybe along these lines [code=php:0] if($_SESSION['agreement']) { //Show page } else { //Show form } Can someone help me out with combining it? Quote Link to comment Share on other sites More sharing options...
Russia Posted October 18, 2009 Author Share Posted October 18, 2009 I got this at the moment. <?php if (isset($_POST['submit2'])) { echo "i dont agree"; } elseif (isset($_POST['submit'])) { echo "i do agree"; } else { ?> //page to read and agree or decline <title>Therm of use</title> <center><h1>Therm of use</h1> <br>Therm of use go here.....</center><br> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="submit" name="submit" value="I agree"> <input type="submit" name="submit2" value="I disagree"> </center> </form> <?php } ?> I would like to also add it so you cannot bypass the first page/visit like page2.php without like a session or something. Like it redirects back. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.