makenoiz Posted December 3, 2007 Share Posted December 3, 2007 FYI: I did read the sticky about headers and I still need help.. thanks....Im not sure of a way around this. I have an index.php file. In that file I have html code: a table and in the table 2 includes to pull in to php files. I get the wonderful headers already sent error. How can I get around this? Should i just use evil Iframes? heeeeeeelllppp thanks makenoiz Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 3, 2007 Share Posted December 3, 2007 you can use ob_start() function in php not too recommended though or as you suggested frame but we can only help if you provide us code Quote Link to comment Share on other sites More sharing options...
makenoiz Posted December 3, 2007 Author Share Posted December 3, 2007 Thanks for your lightning fast reply - wow! Just so you know, I do understand that Im not allowed to send html content to browser before sending php processing. Im just not sure of a way around.... Here is my basic little code. <?php session_start(); echo ' <div align="center"> <p><img src=" /images/header.png" width="800" height="168" /></p> <table width="800" border="1" cellspacing="0" cellpadding="15"> <tr> <td width="380" valign="top" scope="row"><img src="/images/find.gif" width="178" height="40" /></td> <td width="13">'; include "search.php"; echo '</td> <td width="387" valign="top"><img src="/images/edit.gif" width="178" height="40" /></td> </tr> <tr><td valign="top" scope="row"> </td> <td><img src="/images/divider.gif" width="11" height="245" /></td> <td valign="top">'; include "login.php"; echo ' </td> </tr> <tr> <td colspan="3" valign="top" scope="row"><div align="center">Registration is always FREE! </div></td> </tr> </table> <p></p></div>'; ?> Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 3, 2007 Share Posted December 3, 2007 what are your contents of your search.php and login.php Quote Link to comment Share on other sites More sharing options...
makenoiz Posted December 3, 2007 Author Share Posted December 3, 2007 search.php ....... //begin search.php <?php echo 'Search goes here'; ?> //end search.php login.php .......... //begin login.php <?php session_start(); include 'var/obuf.inc.php';// ## db vars if(isset($_POST['login'])) { $username = trim(addslashes($_POST['username'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($query); // now we check if they are activated if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; header("Location: member.php"); } else { echo ' <html> <head> <title>Login</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="error"><p>Sorry, you must activate your account first. Please check your email for the email.</p> <p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div> </body> </html> '; } } else { echo ' <html> <head> <title>Login</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="error"><p>There was an error processing your login, it appears that your username and/or password was incorrect. Please try again.</p> <p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> </div> </body> </html> '; } } else { ?> <html> <head> <title>Login</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="wrapper"> <!-- <div id="head">the login page</div><br>--> <div id="main"> <p>You must login to view this page. Enter your username and password below and hit submit:</p> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> <p>Username:<br> <input name="username" type="text" class="textBox" id="username"> <p>Password:<br> <input name="password" type="password" class="textBox" id="password"> </p> <p> <input name="login" type="submit" class="textBox" id="login" value="Submit"> </p> </form> <p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="register.php">Click here</a> to register, it's completely free! </p> </div> </div> </body> </html> <? } mysql_close($l); ?> //end login.php Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 3, 2007 Share Posted December 3, 2007 you have to restructure most of your code you cannot have a header after session_start(), or put ob_start() if you do not want to modify anything Quote Link to comment Share on other sites More sharing options...
makenoiz Posted December 3, 2007 Author Share Posted December 3, 2007 So I cannot even have session_start in a header.php include at the top of index.php? Will cause same problem? Thank you Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 3, 2007 Share Posted December 3, 2007 sorry phrased myself wrong I meant have output after session_start() and then have a redirect header. Quote Link to comment 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.