Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Bianchine11

Erro PHP - Cannot modify header information - headers already sent by

Recommended Posts

Boa Tarde Pessoal!!

 

Estou com este erro:

Warning: Cannot modify header information - headers already sent by (output started at /home/bullmountain/public_html/progressbar_login/header.php:51) in /home/bullmountain/public_html/progressbar_login/index.php on line 41

Já tentei de tudo! Mudei varias coisas no código e nada :/

Segue códigos das páginas:

 

Index.php

<?php include('header.php');?>
<body>
<br>
<br>
<div class="container">
    <div class="row-fluid">
	<form class="form-horizontal" method="POST">
    <div class="control-group">
    <label class="control-label" for="inputEmail">Username</label>
    <div class="controls">
    <input type="text" id="inputEmail" name="username" placeholder="Username" required>
    </div>
    </div>
    <div class="control-group">
    <label class="control-label" for="inputPassword">Password</label>
    <div class="controls">
    <input type="password" id="inputPassword" name="password" placeholder="Password" required>
    </div>
    </div>
    <div class="control-group">
    <div class="controls">

    <button  id="h-default-trigger" name="login" type="submit" class="btn btn-info">Sign in</button>
    </div>
    </div>
    </form>	
	<?php
	if (isset($_POST['login'])){
		$username=$_POST['username'];
		$password=$_POST['password'];
	
		if ($result = $mysqli->query("SELECT * FROM `user` WHERE `username`='$username' AND `password`='$password'")) {

    		/* determinar el número de filas del resultado */
    		$row_cnt = $result->num_rows;

    		printf("Usuário Autênticado! %d.\n", $row_cnt);

			if ($row_cnt > 0){
				header("location:progressbar.php");
			}

			/* cerrar el resultset */
    		$result->close();
		}
	
		/* cerrar la conexión */
		$mysqli->close();
	
	}
?>
    </div>
</div>
</body>
</html>

header.php

<?php include('dbcon.php');?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>bootstrap-progressbar</title>

    <script type='text/javascript' src="js/jquery.js"></script>
    <script type="text/javascript" src="js/bootstrap-progressbar.js"></script>

    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="css/bootstrap-progressbar.css">

 <style type="text/css">
        .progress .bar.six-sec-ease-in-out {
            -webkit-transition: width 6s ease-in-out;
            -moz-transition: width 6s ease-in-out;
            -ms-transition: width 6s ease-in-out;
            -o-transition: width 6s ease-in-out;
            transition: width 6s ease-in-out;
        }
        .progress.vertical .bar.six-sec-ease-in-out {
            -webkit-transition: height 6s ease-in-out;
            -moz-transition: height 6s ease-in-out;
            -ms-transition: height 6s ease-in-out;
            -o-transition: height 6s ease-in-out;
            transition: height 6s ease-in-out;
        }
        .progress.wide {
            width: 60px;
        }
        .vertical-progressbar-span {
            height: 100px;
        }
    </style>

    <script>
        $(document).ready(function() {
		
               
                $('.progress .bar.text-filled-1').progressbar({
                    display_text: 1,
					         refresh_speed: 200,
                   transition_delay: 500,
             
            });
            
            });
   
</script>
</head>

Progrossbar.php

<?php include('header.php')?>
<body>
<div class="container">
<br>
<br>
<br>
<br>
<br>
<br>
  <div class="span12">
   <script type="text/javascript">
	$(document).ready(function()
		{
		 var delay = 2000;
		setTimeout(function(){ window.location = 'home.php';}, delay);  
    });
	
	

</script>
            <section id="h-default">
              
                <div class="row-fluid">
                   
               
              
						<h2>Loding.....</h2>
                        <div id="prog" class="progress progress-info progress-striped">
                            <div class="bar text-filled-1" data-amount-part="1337" data-amount-total="9000" data-percentage="100"></div>
                        </div>
						
		
             
                </div>
            </section>
            
        </div>
		</div>
		</body>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Nada de HTML antes de header(). Simples assim.

Explico melhor aqui: http://rberaldo.com.br/as-mensagens-de-erros-mais-comuns-do-php/#header

 

Você tem um monte de códigos HTML antes do header(), inclusive um print(). Esse é o problema

Compartilhar este post


Link para o post
Compartilhar em outros sites

On The Fly... Substitui no arquivo index.php a linha:

 

header("location:progressbar.php");

 

Por isto:

 

 

echo "<script>window.location.assign('progressbar.php');</script>";

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.