alvin567 Posted July 12, 2012 Share Posted July 12, 2012 <!-- login functions --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <?php include 'mysql_config.php'; include 'mysql_opendb.php'; ?> <html> <body> <form id="login" action="login.php" method="post"> Email: <input type="text" name="email"/> </br> Password:<input type="password" name="password" maxlength="12"/> </br> <input type="submit" value="submit"> </form> </body> <html> <!--login controller--> <?php if(isset($_POST['email']) && isset($_POST['password'])){ //$email =htmlspecialchars($_POST['email'],ENT_QUOTES);//special character in email $email = $_POST['email']; $password = $_POST['password']; //on alternate flow 3a) password and user id not founded. if( $email != "" || $password != ""){ $sql="SELECT * FROM user WHERE email='".$email."'"; $result=mysql_query($sql); $row=mysql_fetch_array($result); if($password == $row['password']){ header('Location: home.php');//the pages for the members dashboard,set the type of preference. //need to sessions to set the type of users } else{ echo 'Password not founded.Contact PanelPlace SuperAdmin'; } }else{ echo 'Please fill in the username and password'; } } ?> <?php include 'mysql_closedb.php'; ?> Currently working on a login functions,it output the errors as follows in the sites. Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/ Share on other sites More sharing options...
hakimserwa Posted July 12, 2012 Share Posted July 12, 2012 i think the doctype is causing this trauble. firstly it should be wrapped around by the header tag <head></head> Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361017 Share on other sites More sharing options...
Zephni Posted July 12, 2012 Share Posted July 12, 2012 Edit: Oops... I didn't see your <!-- login functions bit at the top --> Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361019 Share on other sites More sharing options...
trq Posted July 12, 2012 Share Posted July 12, 2012 See http://forums.phpfreaks.com/index.php?topic=37442.0 Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361022 Share on other sites More sharing options...
alvin567 Posted July 13, 2012 Author Share Posted July 13, 2012 how any idea? do I write an ob_start() or trim anything before the header('home.php') coding? hakimersara---by wrapping the doctype around the header it doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361209 Share on other sites More sharing options...
alvin567 Posted July 13, 2012 Author Share Posted July 13, 2012 I place exit; after the header('home.php') it doesn't work. I place obstart(); at the top of the script and it doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361211 Share on other sites More sharing options...
alvin567 Posted July 13, 2012 Author Share Posted July 13, 2012 could it be a whitespace bug before <? or ?php> how any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361212 Share on other sites More sharing options...
alvin567 Posted July 13, 2012 Author Share Posted July 13, 2012 Any solutions? ob_start(); //output buffering doesn't works. header('Location:home.php'); ob_end_flush(); Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361220 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2012 Share Posted July 13, 2012 The problem is not the header() statement, its the output you are sending to the browser prior to the header() statement. Did you read error message you are getting? Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361222 Share on other sites More sharing options...
alvin567 Posted July 13, 2012 Author Share Posted July 13, 2012 Warning: Cannot modify header information - headers already sent by (output started at W:\www\project\login.php: in W:\www\project\login.php on line 36 Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361225 Share on other sites More sharing options...
alvin567 Posted July 13, 2012 Author Share Posted July 13, 2012 output already sent by line 8 Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361227 Share on other sites More sharing options...
trq Posted July 13, 2012 Share Posted July 13, 2012 Did you actually read the link I provided? Quote Link to comment https://forums.phpfreaks.com/topic/265555-cannot-modify-header-information-headers-already-sent-by-output-start/#findComment-1361257 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.