sepoto Posted November 27, 2012 Share Posted November 27, 2012 <?phpsession_start(); $productname = trim($_GET['productname']);$productquantity = trim($_GET['productquantity']); if( (!empty($productname) && !empty($productquantity)) && (is_numeric($productquantity)) ) { $_SESSION['productname'] = $productname;$_SESSION['productquantity'] = $productquantity;$_SESSION['sepysCounter'] = 0;header("Location: http://localhost/Form2.php");}else if(empty($productname) || empty($productquantity)){ echo "A value must be entered for both the Product Name and the Quantity text boxes. Please use the back button to go back to the form"; }else if(!is_numeric($productquantity)){echo "The quantity field must be a numeric value";} ?> It's funny I have tried every way I can think of to get rid of the warning but it won't go away unless I completely turn off the display errors property in the configuration. Although the application works perfectly from what I can see. I think it may be this line causing the problem? header("Location: http://bcthub.com/Form2.php"); I see no other way though of writing the code. Could I get some commentary on this? Thank You! Form1.zip Link to comment Share on other sites More sharing options...
Don E Posted November 27, 2012 Share Posted November 27, 2012 Check out this link(post): http://w3schools.invisionzone.com/index.php?showtopic=44106&view=findpost&p=245750 as well as the posts after regarding sessions and the error you're experiencing. Link to comment Share on other sites More sharing options...
sepoto Posted November 27, 2012 Author Share Posted November 27, 2012 (edited) I've read the sticky and I've made an attempt at solving the problem using output buffering however it still is coming at me with the warning: <?phpob_start();session_start(); $productname2 = $_POST['productname2']; if (isset($_POST['countone'])){ if(empty($productname2)){echo "No product name was entered. Use the back button to go back to the form and try again.";}else if($productname2 != $_SESSION['productname']){echo "The product name does not match. The counter was not incremented. Please use the back button and try again.";}else{$sepysCounter = $_SESSION['sepysCounter'];$sepysCounter++;$_SESSION['sepysCounter'] = $sepysCounter;header("Location: http://localhost/Form2.php");}} if (isset($_POST['resetbutton'])){$_SESSION['sepysCounter'] = 0;header("Location: http://localhost/Form2.php");} ob_end_flush();?> Edited November 27, 2012 by sepoto Link to comment Share on other sites More sharing options...
Ingolme Posted November 27, 2012 Share Posted November 27, 2012 There's a line break before your opening <?php tag. That counts as output. Link to comment Share on other sites More sharing options...
sepoto Posted November 27, 2012 Author Share Posted November 27, 2012 I can assure you that as I view my files in Notepad++ on Windows 8 right now that there is no line break before the opening tags in any of my files however I can tell you that the version of PHP provided by my hosting provider is quite old and if I remember correctly is some release of PHP 5.2. Also I can tell you that on my development machine running PHP 5.4 xammpp configuration with display errors on in the php.ini the warning does not appear. PHP 5.4 is winning. Link to comment Share on other sites More sharing options...
birbal Posted November 27, 2012 Share Posted November 27, 2012 Your server probably using "implicit flush", so thus it is outputting anyway.check the setting Link to comment Share on other sites More sharing options...
sepoto Posted November 27, 2012 Author Share Posted November 27, 2012 implicit_flush is set to off on both systems 5.2 @ HostGator and 5.4 @ localhost. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 27, 2012 Share Posted November 27, 2012 The error message tells you exactly where the problem is. It includes the filenames and line numbers for where the output was sent that caused the headers to get sent, and where the line was that tried to send a header after they were already sent. There's no reason to guess. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now