Im Jake Posted March 16, 2008 Share Posted March 16, 2008 Ok, I was wondering how I could do something like this... when you go to www.moparisthebest.org if you dont have a cookie then you are redirected to http://www.moparisthebest.com/agreement.php once u press the i agree button you are redirected back to www.moparisthebest.org. how do i do that? Link to comment https://forums.phpfreaks.com/topic/96360-php-help/ Share on other sites More sharing options...
unsider Posted March 16, 2008 Share Posted March 16, 2008 Look up on: 1. cookies 2. if(isSet(....) { // content } else { 3. header("blah.php"); } 4. if statements It checks if the cookie has been set, if not it most likely uses header to redirect you. I would write a script, but I think it'd be better for you to look up a few things and learn about it, and then come back for questions. Link to comment https://forums.phpfreaks.com/topic/96360-php-help/#findComment-493217 Share on other sites More sharing options...
Im Jake Posted March 16, 2008 Author Share Posted March 16, 2008 Look up on: 1. cookies 2. if(isSet(....) { // content } else { 3. header("blah.php"); } 4. if statements It checks if the cookie has been set, if not it most likely uses header to redirect you. I would write a script, but I think it'd be better for you to look up a few things and learn about it, and then come back for questions. I know almost nothing about php or html, could you write something up, i usually learn from viewing source codes... EDIT: learned vb and java like that. Link to comment https://forums.phpfreaks.com/topic/96360-php-help/#findComment-493218 Share on other sites More sharing options...
Im Jake Posted March 16, 2008 Author Share Posted March 16, 2008 also if i like it ill gie u $15 to paypa; Link to comment https://forums.phpfreaks.com/topic/96360-php-help/#findComment-493219 Share on other sites More sharing options...
unsider Posted March 16, 2008 Share Posted March 16, 2008 whereyoustarted.php <?php if (isset($_COOKIE["valid_user"])) { // show content } else { header("whereyouwannago.php"); } ?> whereyouwannago.php <?php setcookie( /* set whatever */ ); header("whereyoustarted.php"); ?> From that point the content will be showed. Until the user deletes the cookie, and you can choose to destroy the cookie within a specific time frame, etc.., plenty of possiblities. I don't have much time, and I'm not exactly sure what you want to do, but that's the most basic layout for this type of activity. And I don't want your money, go learn though. This stuff is pretty simple. Link to comment https://forums.phpfreaks.com/topic/96360-php-help/#findComment-493222 Share on other sites More sharing options...
Im Jake Posted March 16, 2008 Author Share Posted March 16, 2008 whereyoustarted.php <?php if (isset($_COOKIE["valid_user"])) { // show content } else { header("whereyouwannago.php"); } ?> whereyouwannago.php <?php setcookie( /* set whatever */ ); header("whereyoustarted.php"); ?> From that point the content will be showed. Until the user deletes the cookie, and you can choose to destroy the cookie within a specific time frame, etc.., plenty of possiblities. I don't have much time, and I'm not exactly sure what you want to do, but that's the most basic layout for this type of activity. And I don't want your money, go learn though. This stuff is pretty simple. err... <?php if (isset($_COOKIE["valid_user"])) { // show content } else { header("Termsofservice.php"); } ?> <?php setcookie( /* set whatever */ ); header("www.vbprogramming.org"); ?> wtf. is that right? gah this is so fking confusing. so i save this as ToS.php and thats it? is this coding right? Link to comment https://forums.phpfreaks.com/topic/96360-php-help/#findComment-493225 Share on other sites More sharing options...
unsider Posted March 16, 2008 Share Posted March 16, 2008 This will be my last post, I'm going out for a bit. Here is what you need to do set values for the cookie setcookie(name,value,expire,path,domain,secure) <?php $value = "cookie value"; // cookie that expires in 24 hours setcookie("valid_user",$value, time()+3600*24); ?> <?php // Print cookie echo $_COOKIE["valid_user"]; echo "<br />"; echo $HTTP_COOKIE_VARS["valid_user"]; echo "<br />"; print_r($_COOKIE); ?> wrote this pretty quickly, so might include some type of syntax errors, but maybe another user will be able to help you. Sorry I couldn't do more, if you're still having trouble when I get back I can try to help, otherwise, good luck. Link to comment https://forums.phpfreaks.com/topic/96360-php-help/#findComment-493227 Share on other sites More sharing options...
Im Jake Posted March 16, 2008 Author Share Posted March 16, 2008 <?php if($COOKIE['tos'] == "") { Header("location: tos.php"); } else { Header("Location: main.php"); } ?> would this work ;p? Link to comment https://forums.phpfreaks.com/topic/96360-php-help/#findComment-493229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.