这是我的整个代码,我在行header('location:../registrar/dasboard.php');
说, 警告:无法修改标头信息,已发送标头
下面是我的整个代码
<?php
session_start();?>
<?php include('header.php');
php include('navbar.php');
php include('footer.php')?>
<div class="container">
<div class="margin-top">
<div class="row">
<center>
<img src="../kcwa/kingsway.jpg" class="img-rounded">
</center>
<div class="login">
<div class="log_txt">
<p><strong>Please Enter the Details Below..</strong></p>
</div>
<form class="form-horizontal" method="POST">
<div class="control-group">
<label class="control-label" for="inputEmail">Username :</label>
<div class="controls">
<input type="text" name="username" id="username" placeholder="Username" autofocus required>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password :</label>
<div class="controls">
<input type="password" name="password" id="password" placeholder="Password" required>
</div>
</div>
<div class="control-group">
<div class="controls">
<button id="login" name="submit" type="submit" class="btn"><i class="icon-signin icon-large"></i> Submit</button>
</div>
</div>
</form>
<?php
if (isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysql_query($query)or die(mysql_error());
$num_row = mysql_num_rows($result);
$row=mysql_fetch_array($result);
if( $num_row > 0 ) {
header('location:/registrar/dasboard.php');
$_SESSION['id']=$row['user_id'];
}
else{?>
<div class="alert alert-danger">Access Denied</div>
<?php
}}
?>
</div>
</div>
</div>
</div>
</div>
我尝试了其他解决方案,但我找不到,请帮忙,谢谢
答案 0 :(得分:1)
在尝试标题重定向之前,无法将任何HTML输出到浏览器。错误很明显。如果要在它之前重定向并输出HTML,则必须使用客户端方法,例如JavaScript window.location()。
答案 1 :(得分:0)
我还没有测试过。但试试这样。只需将表单提交php代码放在表单顶部即可。以及下面的代码。你不需要在include函数之前指定php。
php include('navbar.php');
就这样说吧。
include('navbar.php');
尝试这可能它会起作用。