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.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    716
    Thanks
    8
    Thanked 17 Times in 16 Posts

    Accept Terms of use button.

    I have coded this up.

    page1.php

    PHP Code:
    <?php
    if (isset($_POST['submit2'])) {
    //if not agree then load something else
    echo "dont agree";
    }
    elseif (isset(
    $_POST['submit'])) {
    //if agree create session and redirect to next page.
    session_start();
    $_SESSION['confirmed'] = true;
    header("location: page2.php");

    else 
    {
    ?>
    <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
    }

    ?>

    page2.php

    PHP Code:
    <?php
    //starts session
    session_start();
    //checks if button was clicked, if was then loads page
    if(isset($_SESSION['confirmed']) && $_SESSION['confirmed'] == true)
    {
    ?>

    This is your install form.

    <?php
    //destroys session so webpage cannot be accessed again.
    session_destroy();
    }
    else
    {
    //if accessed with no session redirect to main page
    header("location: page1.php");
    exit;  

    ?>
    Its very simple to understand, I used it for my user registration and my php installation form.

  2. Users who have thanked bucket for this post:

    ajloun (11-23-2009)

  • #2
    New Coder
    Join Date
    Oct 2009
    Posts
    78
    Thanks
    1
    Thanked 2 Times in 2 Posts
    nice i would however use setcookie,

    Code:
    if ( $_GET['rules'] == "1" )
    {
        if ( isset($_COOKIE['rules']) ) //we already accepted agreement!
        {
            echo '<script type="text/javascript">window.location="index.php";</script>';
        }
        else //set the cookie 
         {
    
            setcookie( rules, time() + 360000 );
    
    ?>
            <script type="text/javascript">window.location='index.php'</script>
    <?
    
        }
    
    } elseif ( !isset($_COOKIE['rules']) ) //we didnt accept the rules yet, show //them.
    {
    
    
    
    ?>
            <input type=button onClick="parent.location='index.php?rules=1'" value='I Accept'> 
            <input type=button onClick="parent.location='http://google.com'" value='I Decline'> 
    <?
    
        echo '</center>';
    
    }
    }
    if ( isset($_COOKIE['rules']) )
    {
    //index.php code
    }

  • #3
    New Coder
    Join Date
    Oct 2009
    Posts
    78
    Thanks
    1
    Thanked 2 Times in 2 Posts
    i just like setcookie more, plus we can set the time on how long it lasts. like we could say that the user needs to accept the agreement each day.

  • #4
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    setCookie? Why? Sessions are easier to use, and they're killed when someone shuts the browser, why would you want the next person who uses the computer to be able to bypass TOS?
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • #5
    Regular Coder
    Join Date
    Sep 2008
    Posts
    716
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Please thank me on my thread starter post or the script will be removed.
    MY MSN: Sith717@Hotmail.com
    PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
    PM me anytime for HTML, PHP or web design help. I will be glad to help you out.

  • #6
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Quote Originally Posted by bucket View Post
    Please thank me on my thread starter post or the script will be removed.
    Wow, that is very brash of you. If it were worth a thank you, it'd get it. But it is a very simple script.

  • #7
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    Quote Originally Posted by bucket View Post
    Please thank me on my thread starter post or the script will be removed.
    I could literally bash my head against the keyboard hitting a series of keys that would make a more sophisticated script than that gem you are demanding "Thank You's" for.

    In fact I made a point to de-reputate you for said script.

    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • #8
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by kbluhm View Post
    Wow, that is very brash of you. If it were worth a thank you, it'd get it. But it is a very simple script.
    I Win:

    Code:
    <script type="text/javascript">
    function CheckAgree() {
     if(document.terms.agree.checked == true) {
      document.terms.submit();
     }
     else {
      alert("You must agree to the Terms and Conditions!");
     }
    
    }
    </script>
    
    
    <form name="terms" action="http://google.com" method="post">
    <p><input type="checkbox" name="agree" /> Agree to our <a href="http://ispikedthepunch.com">Terms and Conditions</a>.</p>
    <p><a href="#" onclick="CheckAgree();" name="submit">Google</a></p>
    </form>

    So what if it's not PHP!!?!?!? And is full of security holes, bloody well is fun to mess with ^.^.

  • #9
    New Coder
    Join Date
    Oct 2009
    Posts
    78
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Nice one deacon, what if javascript is disabled :P

  • #10
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Thank you .. this will be useful for me sometimes ..

  • #11
    Regular Coder
    Join Date
    Sep 2008
    Posts
    716
    Thanks
    8
    Thanked 17 Times in 16 Posts
    No problem mate, have fun with it.
    MY MSN: Sith717@Hotmail.com
    PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
    PM me anytime for HTML, PHP or web design help. I will be glad to help you out.

  • #12
    New Coder
    Join Date
    Nov 2009
    Location
    www.nn11.darkbb.com
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts
    that demand for a thanks earned a remove of mine.


  •  

    Posting Permissions

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