PHP header errors with CSS?

Discussion in 'CSS Forum' started by Serapis80, Apr 10, 2013.

  1. Serapis80

    Serapis80 New Member

    Well I am having a weird header error upon submitting a form. The error is telling me this:\[quote\] Warning: Cannot modify header information - headers already sent by (output started at index.php:16) in login.php on line 21\[/quote\]The index.php is echoing my form in a heredoc being included from another file.Login.php is \[code\]setcookie()\[/code\]Now I figured out what is messing with it but I can not figure out WHY!When the following CSS is removed, the code work flawlessly.\[code\]body { padding-top: 40px; padding-bottom: 40px; background: #F5F5F5; } .form-signin { max-width: 300px; padding: 19px 29px 29px; margin: 0 auto 20px; background: #FFF; border: 1px solid #E5E5E5; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05); -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05); box-shadow: 0 1px 2px rgba(0,0,0,.05); } .form-signin .form-signin-heading, .form-signin .checkbox { margin-bottom: 10px; }\[/code\]The HTML called in index.php\[code\] <!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8" /> <title>Password Storage Login &middot; Title</title> <link href="http://stackoverflow.com/bootstrap/css/bootstrap.css" rel="stylesheet"> <script type="text/javascript"> $(function(){ $("#open").click(function(){ $("#register").fadeIn('fast'); positionPopup(); }); $("#close").click(function(){ $("#register").fadeOut('fast'); }); }); function positionPopup(){ if(!$("#register").is(':visible')){ return; } $("#register").css({ left: ($(window).width() - $('#register').width()) / 2, top: ($(window).width() - $('#register').width()) / 7, position:'absolute' }); } $(window).bind('resize',positionPopup); </script> <style type="text/css"> body { padding-top: 40px; padding-bottom: 40px; background: #F5F5F5; } .form-signin { max-width: 300px; padding: 19px 29px 29px; margin: 0 auto 20px; background: #FFF; border: 1px solid #E5E5E5; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05); -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05); box-shadow: 0 1px 2px rgba(0,0,0,.05); } .form-signin .form-signin-heading, .form-signin .checkbox { margin-bottom: 10px; } .form-signin input[type="text"], .form-signin input[type="password"] { font-size: 16px; height: auto; margin-bottom: 15px; padding: 7px 9px; } </style> <link href="http://stackoverflow.com/bootstrap/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://stackoverflow.com/bootstrap/js/html5shiv.js"></script> <![endif]--> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="http://stackoverflow.com/bootstrap/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://stackoverflow.com/bootstrap/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://stackoverflow.com/bootstrap/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="http://stackoverflow.com/bootstrap/ico/apple-touch-icon-57-precomposed.png"> <link rel="shortcut icon" href="http://stackoverflow.com/bootstrap/ico/favicon.png"> </head> <body> <center> <h1>Password Vault &middot; Login</h1> <form method="POST" class="form-signin"> <h2 class="form-signin-heading">Please sign in</h2> <input type="text" name="user" size="30" class="input-block-level" placeholder="Username" /><br /> <input type="password" name="pass" size="30" class="input-block-level" placeholder="Password" /><br /> <input type="submit" name="login" class="btn btn-large btn-primary" value="http://stackoverflow.com/questions/15915683/Login" /> <input type="button" class="btn btn-large btn-danger" id="open" value="http://stackoverflow.com/questions/15915683/Register" /> </form> <div id="register" style="display:none;background:url(/images/bg-reg.png);width:100%;height:100%;"> <form method="POST" id="regform" class="form-signin" style="margin-top:50px;"> <h2 class="form-signin-heading">Registration</h2> <input type="text" name="ruser" size="30" class="input-block-level" placeholder="Username" /><br /> <input type="password" name="rpass" size="30" class="input-block-level" placeholder="Password" /><br /> <input type="password" name="mpass" size="30" class="input-block-level" placeholder="Master Password" /><br /> <input type="text" name="email" size="30" class="input-block-level" placeholder="Email" /><br /> <input type="submit" name="register" class="btn btn-large btn-primary" value="http://stackoverflow.com/questions/15915683/Register" /> <input type="button" class="btn btn-large btn-inverse" id="close" value="http://stackoverflow.com/questions/15915683/Close" /><br /><br /> *The master password will be used to decrypt your list of passwords! </form> </div> </center> </body></html>\[/code\]and finally, login.php\[code\]$db->Query("SELECT `user`,`pass` FROM `users` WHERE `user`='$user'");$res = $db->get();if(count($res) > 0){ if($res[0]['pass'] == md5($pass)){ $sessionhash = cookiegen($user); $db->Query("UPDATE `users` SET `session_hash`='$sessionhash' WHERE `user`='$user'"); setcookie('logintoken',$sessionhash,time()+43200,'/',$url,0,0); $_SESSION['user'] = $user; #echo "<script>window.location = '?do=login';</script>"; }} else { echo <<<FORM <center> <div class="alert alert-error" style="width:360px;"> <button type="button" class="close" data-dismiss="alert">&times;</button> <strong>Warning!</strong> That user was not found! </div> </center>FORM;}\[/code\]index.php\[code\]echo $loginForm; if(isset($_POST['login'])){ $user = mysql_real_escape_string($_POST['user']); $pass = mysql_real_escape_string($_POST['pass']); if(empty($user)){ if(empty($pass)){ die($noUserPass); } else { die($noUser); } } if(!empty($user)){ if(empty($pass)){ die($noPass); } else { include('/inc/login.php'); } } }\[/code\]
     

Share This Page