Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts

    Accept Terms of Agreement button

    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.

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Maybe along the lines of

    if($_SESSION['agreement'])
    {
    //Show page
    }
    else
    {
    //Show form
    }

    ?

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    PHP Code:
    if(isset($_POST['checkBoxName']) && $_POST['checkBoxName']=="checked")) 
    i think
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #4
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Okay so I got this for now.

    Code:
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="blah" NAME="blah" onSubmit="return validateData()">
    and
    Code:
    <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>
    So how would I integrate what you guys gave me to this?

    I would like to put them together.
    Last edited by bucket; 10-18-2009 at 03:04 PM.

  • #5
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here a simple example add your code and modify it like you want

    PHP Code:
    <?php
    if (isset($_POST['submit'])) {
    //your page if agreed
    } 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
    }
    if (isset(
    $_POST['submit2'])) {
    //code for if don't agree
    }
    ?>

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by bucket View Post
    Okay so I got this for now.

    Code:
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="blah" NAME="blah" onSubmit="return validateData()">
    and
    Code:
    <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>
    So how would I integrate what you guys gave me to this?

    I would like to put them together.
    Don't use JavaScript for the buttons, use a form and have it submit and process the user's choice on the server side.
    OracleGuy

  • #7
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Quote Originally Posted by powerfear View Post
    Here a simple example add your code and modify it like you want

    PHP Code:
    <?php
    if (isset($_POST['submit'])) {
    //your page if agreed
    } 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
    }
    if (isset(
    $_POST['submit2'])) {
    //code for if don't agree
    }
    ?>
    Its not working at all, nothing shows up when I click I agree.

    Okay so thats the whole thing?
    Last edited by bucket; 10-18-2009 at 06:02 PM.

  • #8
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    PHP Code:
    <?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
    }

    ?>
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #9
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    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.

  • #10
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    what is the URL of this page and what is the URL of page2?
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #11
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    first page index.php

    and the second page is index2.php


    Il edit them by myself. Just make it like page1 and page2.php.

    Thank You phil.

  • #12
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Any luck phil?

  • #13
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    untested.. wrote it quick, but should work. Also not bullet proof but added security

    PHP Code:
    <?php

    function throughRefererOnly($pageRedirect$fullPageDir$referer$errorMsg
    {
        
    $PQwebsite preg_quote($fullPageDir"#");
        if(!
    preg_match("#^".$PQwebsite."$#is"$referer))
        {
            
    header("location: ".$pageRedirect."?error=".$errorMsg);
            exit;
        }
    }

    $pageRedirect "http://www.yourwebsite.co.uk/index.php";
    $fullPageDir "http://www.yourwebsite.co.uk/index2.php";
    $errorMsg "You do not have permission to access those files.";

    // here you should put something like if(!isset($_POST['submitButton'])) {  header("location: ".$pageRedirect."?error=".$errorMsg); exit; }
    throughRefererOnly($pageRedirect$fullPageDir$_SERVER['HTTP_REFERER'], $errorMsg);

    //recall error on index.php through if(isset($_GET['error'])) { echo $_GET['error']; }
    ?>
    add to the top of index2.php and fill in the required variables
    Last edited by Phil Jackson; 10-18-2009 at 10:46 PM.
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #14
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    kk thanks

  • #15
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Doesn't seem to work.

    Try it yourself.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •