BoltZ Posted October 25, 2008 Share Posted October 25, 2008 Ok I have this code in my index.php file <?php setcookie("step1", "bboardx", time()+3600); if( isset($_COOKIE['step1'])) { include('step1.php'); } if( isset($_COOKIE['step2']) && (!isset($_COOKIE['step1']))) { include('step2.php'); } ?> and this in my addcookie.php file which in step1 there is a button for (note to see a link its www.devwebsites.com/forums/install/index.php) <?php if(!isset($_COOKIE['step2']) && (isset($_COOKIE['step1']))) { setcookie("step2", "bboardx", time()+3600); setcookie("step1"); } header('Location:http://www.devwebsites.com/forums/install/index.php'); ?> The design is to have it so the default is the welcome page. then when the user clicks the next button it adds a cookie for step2then it deletes step1 cookie, then it redirects back to the same page. this time if step2 cookie exists and step1 cookie doesnt then it includes step2.php file instead of step1.php. However when I click the button it just goes to teh same step which is the welcome screen and it doesn't go to step 2. Any ideas why It isn't working? Just so you guys know here is step1.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>BBoardX Installation Guide- Step 1</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="" /> <link rel="stylesheet" type="text/css" href="stylesheet.css" /> <link rel="icon" type="image/png" href="favicon.ico" /> </head> <body><div class="header"><img src="images/logo.gif" alt="banner" width="700px" /></div> <div class="bluestrip">BBoardX Installation Guide</div> <table><tr><td> <div class="leftside"><ul> <li><img src="images/greaterthen.gif" alt="bullet" /> <strong> Welcome</strong></li> <li>View License</li><li>Meet Requirements</li><li>Configure DB</li> <li>Create Tables</li><li>Insert Data</li><li>Install Themes</li> <li>Configure Board</li><li>Create Admin</li><li>Finish Setup</li> </ul></div><div class="overlap"> <div class="rightside"><img src="images/checkmark.jpeg" alt="check" style="display:block; width: 70px; height:70px; float:left;" /><h2 style="float:left;"> Welcome</h2></div> <div class="content"><p><br /><br /><br /><br /><br /><br />Welcome to the first step to installing your very own BBoardX Forums! When you are done with this easy setup, you will have a BBoardX style forum on your website. </p><p> Now that you have uploaded all the required files into your forum directory lets start the installation process. On the left hand side is a list of the steps in the installation process. <br /></p> <p>When you are done each step in the installation process click the "Next" button to proceed.</p> <p>Click the "Next" button to continue the installation process</p> <div class="button"> <form action="addcookie.php" method="post"><div> <input type="submit" value=">> Next" name="step1" /></div> </form></div></div></div></td></tr></table></body></html> Sorry if it is hard to read Quote Link to comment https://forums.phpfreaks.com/topic/130092-cookies-make-different-forms/ Share on other sites More sharing options...
kenshintomoe225 Posted October 25, 2008 Share Posted October 25, 2008 setcookie("step1"); This sets "step1" to "", so even though its an empty string, its still set. To delete your cookie try setcookie("step1", "", time() - 3600); To force it to expire. Also, if your page is redirecting to the index.php page: setcookie("step1", "bboardx", time()+3600); is sitting right there at the top, setting "step1" again. Is this what you intended, or am I reading this wrong? Quote Link to comment https://forums.phpfreaks.com/topic/130092-cookies-make-different-forms/#findComment-674552 Share on other sites More sharing options...
BoltZ Posted October 25, 2008 Author Share Posted October 25, 2008 Yea sorry I forgot to update this thread saying I already figured it out by myself. Ironically enough it was the method you tried. Now i need everyone to go to www.devwebsites.com/forums/install/ and notice that there is a cookie problem. At least I think there is..it may be because i keep setting the cookies and everything. but to test out this bug (note that b4 u do what i say you to do you must have a clear look at everything since the cookiee expires in ONE hour) you have to click the next button then reload the page. both step1 and step 2 will display. Any way to make it so it never displays 2 steps again? Quote Link to comment https://forums.phpfreaks.com/topic/130092-cookies-make-different-forms/#findComment-674622 Share on other sites More sharing options...
kenshintomoe225 Posted October 25, 2008 Share Posted October 25, 2008 I clicked on the link and got a blank page. What is the current code you are using? Quote Link to comment https://forums.phpfreaks.com/topic/130092-cookies-make-different-forms/#findComment-674630 Share on other sites More sharing options...
BoltZ Posted October 25, 2008 Author Share Posted October 25, 2008 The link is fine. Try again.... Quote Link to comment https://forums.phpfreaks.com/topic/130092-cookies-make-different-forms/#findComment-674695 Share on other sites More sharing options...
BoltZ Posted October 25, 2008 Author Share Posted October 25, 2008 oh when u click on the link it will display blank, then reload the page again and it will show. sorry also you know how to fix that? i set a cookie before the if statements begin but for some reason it doesn't dispplay unless i refresh the page, anyidea how to fix that? Quote Link to comment https://forums.phpfreaks.com/topic/130092-cookies-make-different-forms/#findComment-674703 Share on other sites More sharing options...
kenshintomoe225 Posted October 25, 2008 Share Posted October 25, 2008 when you set the cookie, the script isn't going to pick it up until the page is refreshed, thats the nature of cookies. you could use the redirect function to refresh the page when the cookie is set, and then don't refresh anymore. http://us.php.net/header See if that helps, then we can proceed. Quote Link to comment https://forums.phpfreaks.com/topic/130092-cookies-make-different-forms/#findComment-674710 Share on other sites More sharing options...
BoltZ Posted October 25, 2008 Author Share Posted October 25, 2008 Nah I didnt need that. see the simplicity of my page is that it sets the cookie then its a series of if statements to display the step. i decided to put in an else statement which the default is to reload the page and so its flawless. It works now go ahead n try it. try to solve the problem i had before about 2 steps being displayed Quote Link to comment https://forums.phpfreaks.com/topic/130092-cookies-make-different-forms/#findComment-674714 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.