请帮助我:当我锁定登录按钮时,显示错误,我无法解决这个问题。我是 php 新手。
警告:无法修改标头信息 - 标头已由第 56 行 /home/kanak/public_html/celltopc/login.php 中的(输出开始于 /home/kanak/public_html/celltopc/login.php:33)发送
我的代码是:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<link href="css/usercss.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-image: url(images/LoginForm_bg.jpg);
background-repeat: repeat;
}
-->
</style></head>
<body>
<div class="shadow" id="login">
<div id="login-body">
<form action="login.php" method="post" name="loginform">
<strong>Username:</strong>
<input name="username" type="text" class="input" value="username" maxlength="10" />
<p><br />
<strong>Password:</strong>
<input name="password" type="password" class="input" value="password" />
<p><br />
<input type="submit" name="submit" value="Login" width="30" class="myButton">
</form>
<p> <br />
<?php
ob_start();
@session_start();
include'include/config.php';
include'include/opendb.php';
@$username=$_POST['username'];
@$password=$_POST['password'];
if($username&&$password)
{
$connect=mysql_connect("$dbhost","$dbuser","$dbpass")or die("Couldnt connect to Database");
mysql_select_db("$dbname") or die ("Could not find to Database");
$query = mysql_query ("SELECT * FROM user WHERE username='$username'");
$numrows = mysql_num_rows($query);
if ($numrows != 0)
{
while ($rows = mysql_fetch_assoc($query))
{
$dbusername = $rows['username'];
$dbpassword = $rows['password'];
}
if($username==$dbusername&&$password==$dbpassword)
{
header("location:main.php");
$_SESSION['username']=$dbusername;
}
else
die("<p class=error>* Increate Password</p>");
}
else die("<p class=error>* The username doesnot exist</p>");
}
else die ("<p class=text>* Please entre a username and password</p>");
?>
</div>
</div>
</body>
</html>