Yesideez Posted May 7, 2009 Share Posted May 7, 2009 Any idea how I can get around this? I've got a submit button that isn't being picked up and I've isolated the cause of the problem to be ob_start(). If I comment out that line everything works smoothly. only problem is, I need to buffer all the output! Link to comment https://forums.phpfreaks.com/topic/157213-ob_start-clears-all-my-_post-vars/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2009 Share Posted May 7, 2009 ob_start has nothing to do with the receipt of external data. It's more likely you have invalid HTML that is preventing the form from working. In any case, you would need to post your form and your form processing code for anyone to be able to tell you anything about what your code is doing or not doing. Why are you using ob_start anyway, it's likely masking errors in your logic that are preventing it from working correctly in the first place. Link to comment https://forums.phpfreaks.com/topic/157213-ob_start-clears-all-my-_post-vars/#findComment-828380 Share on other sites More sharing options...
Yesideez Posted May 7, 2009 Author Share Posted May 7, 2009 It's strange that when ob_start() is removed it works perfectly fine and when I add it, it fails. This is the page with the submit button (in this case a login script) <?php /* File : admin/index.php ** Created: 17-Apr-2009 (Ivan Rood) ** Edited : N/A ********************************************************************/ require('config.php'); $strMsg='Please login'; $strUsername=(isset($_POST['username']) ? $_POST['username'] : ''); $strPassword=(isset($_POST['password']) ? $_POST['password'] : ''); $strCaptcha=(isset($_POST['captcha']) ? $_POST['captcha'] : ''); if (isset($_POST['sublogin'])) { if (isset($_SESSION['vercode']) && $_SESSION['vercode']==sha1($strCaptcha)) { if ($strUsername==$prefs->username && sha1($strPassword)==$prefs->password) { $prefs->saveSession(); $_SESSION['loggedin']=true; header('Location: home.php'); exit; } else { $strMsg='Invalid username/password'; } } else { $strMsg='Invalid security code'; } } ?> <html> <?php include('html_head.php'); ?> <body> <?php include('html_header.php'); ?> <p class="spacer"> </p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table align="center" cellspacing="0" class="boxinfo"> <tr><td colspan="2" align="center"><strong><?php echo $strMsg; ?></strong></td></tr> <tr><td>Username</td><td><input type="text" name="username" maxlength="20" class="gadstr"></td></tr> <tr><td>Password</td><td><input type="password" name="password" class="gadstr"></td></tr> <tr><td colspan="2" align="center"><img src="../makeimg.php?i=<?php echo mt_rand(1000,9999); ?>" alt="" width="130" height="34" style="margin-bottom: 2px"><br><input type="text" name="captcha" size="6" maxlength="6" class="gadstr captcha"></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="sublogin" value="Login" class="gadbut"></td></tr> </table> </form> <p class="spacer"> </p> <?php include('html_footer.php'); ?> </body> </html> Here is the content of config.php: <?php session_start(); //if (isset($_POST['sublogin'])) {echo 'Yes';} else {echo 'No';} //ob_start(); $basedir=dirname(__FILE__); require($basedir.'/../config.php'); require($basedir.'/../siteprep.php'); ?> If I uncomment the if() statement it works and it says "Yes". If I then uncomment the ob_start() it fails and says "Yes" still. Link to comment https://forums.phpfreaks.com/topic/157213-ob_start-clears-all-my-_post-vars/#findComment-828382 Share on other sites More sharing options...
Yesideez Posted May 7, 2009 Author Share Posted May 7, 2009 btw, I tried the if() after the ob_start() and when commented out the second if() I get "YesYes". Uncomment it and I get "YesNo" Link to comment https://forums.phpfreaks.com/topic/157213-ob_start-clears-all-my-_post-vars/#findComment-828389 Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2009 Share Posted May 7, 2009 The symptoms you are getting are indicative of a page being requested twice or an include/require being included/required more than once. Either your browser is requesting the page more than once, you have a url rewrite that is causing the page to be requested more than once, you have an include/require that in being included/required more than once, or you have a redirect that is causing the page to be re-requested. Link to comment https://forums.phpfreaks.com/topic/157213-ob_start-clears-all-my-_post-vars/#findComment-828399 Share on other sites More sharing options...
Yesideez Posted May 7, 2009 Author Share Posted May 7, 2009 Thanks for that - I'll start removing some items until I get to the root of the problem... I never thought it could be the page being requested more than once! Link to comment https://forums.phpfreaks.com/topic/157213-ob_start-clears-all-my-_post-vars/#findComment-828402 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.