Jump to content

Accept Terms and Conditions Button


Russia

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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()"><

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.