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
https://forums.phpfreaks.com/topic/178074-accept-terms-and-conditions-button/
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.

 

 

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

 

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?

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.

 

Archived

This topic is now archived and is closed to further replies.

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