Cory94bailly Posted May 15, 2008 Share Posted May 15, 2008 Does ob_start(); make it so you can not add a new cookie? Because I double checked and triple checked my code.. and it's fine.. Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/ Share on other sites More sharing options...
revraz Posted May 15, 2008 Share Posted May 15, 2008 It's a output buffer http://us2.php.net/ob_start Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542357 Share on other sites More sharing options...
Cory94bailly Posted May 15, 2008 Author Share Posted May 15, 2008 It's a output buffer http://us2.php.net/ob_start Yes....... I know that much.. So does it make it so you can't set a cookie? Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542363 Share on other sites More sharing options...
DarkWater Posted May 15, 2008 Share Posted May 15, 2008 Actually, ob_start() usually HELPS you set cookies. Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542364 Share on other sites More sharing options...
revraz Posted May 15, 2008 Share Posted May 15, 2008 It suppresses output and stops the Header error from appearing. But instead of using it, you should rethink your logic and code it so you don't need the buffer. Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542368 Share on other sites More sharing options...
DarkWater Posted May 15, 2008 Share Posted May 15, 2008 @revraz: Sometimes ob_start() is the best way to keep your program in a logical flow. Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542377 Share on other sites More sharing options...
revraz Posted May 15, 2008 Share Posted May 15, 2008 Never had to use it once. @revraz: Sometimes ob_start() is the best way to keep your program in a logical flow. Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542378 Share on other sites More sharing options...
Cory94bailly Posted May 15, 2008 Author Share Posted May 15, 2008 Actually, ob_start() usually HELPS you set cookies. Well it doesn't seem to help me Login.php code: <?php //**********Start Member Login!**********\\ ob_start(); error_reporting(E_ALL); // Connects to your Database mysql_connect("***", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); //Checks if there is a login cookie if(isset($_COOKIE['ID_fcs_member'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['ID_fcs_member']; $pass = $_COOKIE['Key_fcs_member']; $check = mysql_query("SELECT * FROM members WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: ***"); } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } // checks it against the database if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM members WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database. <a href="register.php">Click Here to Register</a>'); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_fcs_member, $_POST['username'], $hour); setcookie(Key_fcs_member, $_POST['pass'], $hour); //then redirect them to the members area header("Location: ***"); } } } else { } ob_end_flush(); //**********End Member Login!**********\\ ?> It should redirect me to the index.php but it just again, shows me the normal login page (Note: "***" = Don't want you to know now..) And: It suppresses output and stops the Header error from appearing. But instead of using it, you should rethink your logic and code it so you don't need the buffer. Well I tried that but nobody here helped me with it sooo.. Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542379 Share on other sites More sharing options...
Cory94bailly Posted May 15, 2008 Author Share Posted May 15, 2008 BUMP Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542426 Share on other sites More sharing options...
DarkWater Posted May 15, 2008 Share Posted May 15, 2008 Does it give any errors? Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542434 Share on other sites More sharing options...
Cory94bailly Posted May 15, 2008 Author Share Posted May 15, 2008 Does it give any errors? Nope... But the weird thing is, I think it's actually putting the cookie but not redirecting me and my "loggedin.php" always shows me as logged out... Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542438 Share on other sites More sharing options...
BlueSkyIS Posted May 15, 2008 Share Posted May 15, 2008 Never had to use it once. @revraz: Sometimes ob_start() is the best way to keep your program in a logical flow. ditto. Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542449 Share on other sites More sharing options...
gizmola Posted May 15, 2008 Share Posted May 15, 2008 Probably a logic error, with all your nested empty loops all over the place, and no indention your code is impossible to follow. I don't want to take the time to indent your code just to figure out what you're doing, but I willl suggest that you break things up into smaller more discrete pieces, perhaps even using "functions". You might even want to try your hand at a simple flow chart. Link to comment https://forums.phpfreaks.com/topic/105823-solved-ob_start/#findComment-542479 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.