I have the following php / html page. The register_script.php which is called at the top of the html page has a header redirect. I get the standard error msg stating that the header cannot be sent because headers have already been sent. I understand why. The only way I can fix this is to put the php include before everything else. The form works this way but Expression Web flags all kinds of "errors" because the schema is not right. I would like to clean this up and make it work right. I have tried ob_start() with ob-flush() and ob_end_clean() all to no avail. Anybody have any other ideas? It just should not be so hard get a redirect to work in php. Any help would be appreciated. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php include('../php_scripts/register_script.php'); ?> <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <!-- #BeginTemplate "../master.dwt" --> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <!-- #BeginEditable "doctitle" --> <title>ATFTC Registration</title> <script language="javascript" src="../jscript/gen_validatorv31.js" type="text/javascript"></script> <style type="text/css"> .style6 { color: #000000; visibility: hidden; } </style> <!-- #EndEditable --> <link href="../styles/atftc.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .style3 { font-style: normal; } </style> </head> <body> <!-- Begin Container --> <div id="container"> <!-- Begin Masthead --> <div id="masthead"> <div> <img src="../images/atftc_round_125.gif" alt="atftc round logo" style="width: 129px; height: 125px; position: absolute; top: 8px; left: 150px; z-index: 1;" /></div> <div> <object id="flash1" data="../images/atftc_new_white.swf" style="width: 1250px; height: 145px; overflow: hidden; " type="application/x-shockwave-flash"> <param name="movie" value="../images/atftc_new_white.swf" /> <param name="quality" value="High" /> <param name="salign" value="T" /> <param name="loop" value="false" /> <param name="wmode" value="transparent" /> </object> </div> <p>American Toy Fox Terrier Club</p> </div> <!-- End Masthead --> <!-- Begin Page Content --> <div id="page_content"> <!-- Begin Sidebar --> <div id="sidebar" style="left: 0px; top: 14px"> <a href="../index.html">Home</a> <a href="../about/about.htm">About TFTs</a> <a href="../breed_std/breed_std.htm">Breed Standard</a> <a href="../health/health.htm">Health Info</a> <a href="../pictures/pictures5.htm">Pictures</a> <a href="../performance/performance.htm">Performance</a> <a href="../rescue/rescue.htm">TFT Rescue</a> <a href="../breeders/breeders.htm">Find a Breeder</a> <a href="../board/board.htm">Board Members</a> <a href="../join/join.htm">Join the ATFTC</a> <a href="../forms/forms.htm">Forms</a> <a>________________</a> <a href="../bulletin_board/bulletin_board.htm">Bulletin Board</a> <a href="../nationals/nationals.htm">Nationals and Regionals</a> <a href="../top_twenty/2008TopTFT.htm">Top Twenty TFTs</a> <a href="login.php">Members Only</a> <a>________________</a> <a> <form action="http://www.google.com/cse" id="cse-search-box"> <div> <input type="hidden" name="cx" value="015521534810976091176:6ytwsum24n4" /> <input type="hidden" name="ie" value="UTF-8" /> <input type="text" name="q" size="17" /> <input type="submit" name="sa" value="Search" /> </div> </form> <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script> </a> </div> <!-- End Sidebar --> <!-- Begin Content --> <div id="content"> <!-- #BeginEditable "content" --> <h1>Register for a Username and Password</h1> <h3>(If you already have a username and password, please <a href="login.php">login</a>.)</h3> <p>All fields are required.</p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="my_form"> <table border="0"> <tr><td style="width: 131px">Username:</td><td> <input type="text" name="username" maxlength="18" style="width: 200px" /> </td></tr> <tr><td style="width: 131px">Password:</td><td> <input type="password" name="pass" maxlength="18" style="width: 200px" /> </td></tr> <tr><td style="width: 131px">Confirm Password:</td><td> <input type="password" name="pass2" maxlength="18" style="width: 200px" /> </td></tr> <tr><td style="width: 131px">First Name:</td><td> <input name="firstname" maxlength="50" style="width: 200px" /></td></tr> <tr><td style="width: 131px">Last Name:</td><td> <input name="lastname" maxlength="50" style="width: 200px" /></td></tr> <tr><td style="width: 131px">Email Address:</td><td> <input name="email_addr" maxlength="50" style="width: 200px" /></td></tr> <tr><td style="width: 131px">Confirm Email:</td><td> <input name="email_addr1" maxlength="50" style="width: 200px" /></td></tr> <tr><td style="width: 131px"> <input class="style6" name="field1r" type="text" value="03Jdz0101" tabindex="0" /></td><td> <input class="style6" name="field2r" type="text" value="" tabindex="0" /></td></tr> <tr><th colspan="2" class="style1"><input type="submit" name="submit" value="Register" /></th></tr> </table> </form> <p>Both your username and password must be at least 6 characters long and no more than 16 characters long. Your password must be different than your username.</p> <script language="javascript" type="text/javascript"> //You should create the validator only after the definition of the HTML form var frmvalidator = new Validator("my_form"); frmvalidator.EnableMsgsTogether(); frmvalidator.addValidation("username","req","A username is required."); frmvalidator.addValidation("pass","req","A password is required."); frmvalidator.addValidation("pass2","req","A confirmation password is required."); frmvalidator.addValidation("firstname","req","Your first name is required."); frmvalidator.addValidation("lastname","req","Your last name is required."); frmvalidator.addValidation("email_addr","req","Your e-mail address s required."); frmvalidator.addValidation("email_addr1","req","Your confirmation e-mail address is required."); frmvalidator.addValidation("email_addr","email","Your E-mail Address is not valid."); frmvalidator.addValidation("email_addr1","email","Your confirmation E-mail Address is not valid."); </script> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <!-- #EndEditable --></div> <!-- End Content --></div> <!-- End Page Content --> <!-- Begin Footer --> <div id="footer"> <p><a href="../index.html">Home</a> | <a href="../about/about.htm">About</a> | <a href="../breed_std/breed_std.htm">Breed Standard</a> | <a href="../health/health.htm">Health</a> | <a href="../pictures/pictures5.htm">Pictures</a> | <a href="../performance/performance.htm">Performance</a> | <a href="../rescue/rescue.htm">Rescue</a> | <a href="../breeders/breeders.htm">Breeders</a> | <a href="../board/board.htm">Board</a> | <a href="../join/join.htm">Join</a> | <a href="../forms/forms.htm">Forms</a> </p><p> <a href="../bulletin_board/bulletin_board.htm">Bulletin Board</a> | <a href="../nationals/nationals.htm">Nationals</a> | <a href="../top_twenty/2008TopTFT.htm">Top Twenty</a> | <a href="login.php">Members Only</a> <br /> </p> <p><em>Copyright © 2009 American Toy Fox Terrier Club. All Rights Reserved.<span class="style3"> </span>Website designed by <a href="mailto:webmaster@atftc.com">John David Zieba</a>.</em></p> </div> <!-- End Footer --></div> <!-- End Container --> </body> <!-- #EndTemplate --> </html> Code (markup):
Best route... don't output any html until after you got your data figured out. Meaning most of the PHP so be before <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> even happens.
Another way of tracking this issue is create a header.php where you start session and ob_start() and include this file in all pages before starting page content. You can even include your header details inside the header.php so that you can avoid multiple defining of the header tags. Then create a footer.php file where you do ob-flush() and ob_end_clean() Hope this will work