Im Jake Posted May 25, 2008 Share Posted May 25, 2008 <?php $cookiename = "RFant_agree"; $cookiecontent = "yes"; if(isset($_COOKIE[$cookiename])){ header("Location: http://".$_SERVER['SERVER_NAME']."/index.php"); } elseif(isset($_POST['Cancel'])){ die("You must agree to the TOS to view the site, sorry."); } elseif(isset($_POST['Submit']) && (strtolower($_POST['agree']) == "yes")){ setcookie($cookiename, $cookiecontent, time() + 2592000); // $fp = fopen("log" , "a" ); // fwrite($fp, $_SERVER['REMOTE_ADDR']."\n"); // fclose($fp); if(isset($_GET['returnto'])) header("Location: ".$_GET['returnto']); else header("Location: http://".$_SERVER['SERVER_NAME']."/index.php"); } else { showheader(); showTOS(); echo '<font color="white">Type <i>\'yes\'</i> if you agree to <i>ALL</i> of the above terms.<br /> You must have cookies enabled for this to work.</font> <br />'; if(isset($_GET['returnto'])) echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."?returnto=".$_GET['returnto']."\">"; else echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">"; echo ' <input name="agree" size="20" /><br /> <input type="submit" name="Submit" value="I Agree" /> <input type="submit" name="Cancel" value="Cancel" /> </form>'; showfooter(); } function showheader() { echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>'.$_SERVER['SERVER_NAME'].' TOS</title> <style type="text/css"> body{font-family: verdana; font-size: 10pt;} div{background: #3d71ad; width: 70%; border: 1px solid black; font-family: verdana; font-size: 10pt;} input{border: 1px solid black;} </style> </head> <body bgcolor="#666666"> <center> <div> <b>'.$_SERVER['SERVER_NAME'].' Terms of Service</b> </div> <br /> '; } function showfooter() { echo '</center> </body> </html>'; } function showTOS() { echo '<div style="text-align: left;"> <tt> By typing <i>\'yes\'</i> you agree to everything stated below:<br /><br /> You are not an employee of Jagex LTD, runescape, or adlex solicitors, and are not a family member or acquaintance of the aforementioned.<br /><br /> All of the information on this site is solely for learning purposes, as the main purpose of this site is to instruct people in the art of programming. All programs provided for download from this site are entirely coded by the members of this community and are not the intellectual property of any business or organization. </tt> </div> <br /> <div style="text-align: left;"> <tt> In order to use the forum you must agree to all of these rules as well:<br /> <ol> <li>We are not anti-leech. If you respect our community and our ideas, feel free to ask questions and they will be kindly answered if you follow other rules. Answer to questions that others ask if you know the answer or remain silent!</li><br /> <li>We don\'t talk about things we don\'t know. This is an informative, not uninformative community.</li><br /> <li>We don\'t make spelling mistakes on purpose. We use "you" not "u", we use "why" not "y" etc.</li><br /> <li>We don\'t make posts that contain useless information. Posts like "cool", "lol", "yeah" and "I agree" don\'t contain anything useful for others. We are not fans of off topic, unless it contains something smart or funny. Most of things spammers find funny are actually not funny at all.</li><br /> <li>We don\'t "bump" or double post.</li><br /> <li>We respect each other and other communities. We don\'t flame each other or other communities. We don\'t fight on the forums.</li><br /> <li>We don\'t advertise other sites or communities unless we ask and receive permission to.</li><br /> <li>We don\'t care about post count alone. If someone has high post count and most of it is spam, we hate him. If someone has high post count with informative posts, we love him. The higher count, the more we hate/love him.</li><br /> <li>DO NOT post or upload any copyrighted materials, ie deobs, clients or any other sort.</li><br /> <li>We don\'t sell anything on these forums.</li><br /> <li>We never have misleading links in your signatures. If your signature says www.google.com, we expect it to take us to google.com.</li><br /> </ol> </tt> </div> <br /><br />'; } ?> This is my code, I want it so that if you dont have the cookie RFant_agree then you get redirected to www.mydomain.com/tos.php and when you type yes and agree it takes you to where you were going... Link to comment https://forums.phpfreaks.com/topic/107195-if-you-dont-have-this-take-you-to-this/ Share on other sites More sharing options...
Im Jake Posted May 25, 2008 Author Share Posted May 25, 2008 Help please? Link to comment https://forums.phpfreaks.com/topic/107195-if-you-dont-have-this-take-you-to-this/#findComment-549765 Share on other sites More sharing options...
unidox Posted May 25, 2008 Share Posted May 25, 2008 <?php if (!$_COOKIE['RFant_agree']) { header("Location: tos.php"); exit(); } ?> Then in TOS.php: <?php if (isset($_POST['check'])) { $_COOKIE['RFant_agree'] = 1; header("Location: index.php"); exit(); } ?> Link to comment https://forums.phpfreaks.com/topic/107195-if-you-dont-have-this-take-you-to-this/#findComment-549791 Share on other sites More sharing options...
marcus Posted May 25, 2008 Share Posted May 25, 2008 That's not how you would change a cookie... that's how you call a cookie. To change or create a new cookie you need to use setcookie, cookies dont work like sessions. Link to comment https://forums.phpfreaks.com/topic/107195-if-you-dont-have-this-take-you-to-this/#findComment-549793 Share on other sites More sharing options...
Im Jake Posted May 25, 2008 Author Share Posted May 25, 2008 what? Link to comment https://forums.phpfreaks.com/topic/107195-if-you-dont-have-this-take-you-to-this/#findComment-549797 Share on other sites More sharing options...
Darklink Posted May 25, 2008 Share Posted May 25, 2008 Look up the function, setcookie. Link to comment https://forums.phpfreaks.com/topic/107195-if-you-dont-have-this-take-you-to-this/#findComment-549804 Share on other sites More sharing options...
unidox Posted May 25, 2008 Share Posted May 25, 2008 Oh, I thought he wanted to pass the cookie... Link to comment https://forums.phpfreaks.com/topic/107195-if-you-dont-have-this-take-you-to-this/#findComment-549827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.