PHP Header related issues

Source: Internet
Author: User
PHP header Problem
The code appears as follows Warning:cannot Modify header Information-headers already sent by (output started at D:\APPSERV\WWW\ADMIN_CHEC k.php:1) in D:\AppServ\www\admin_check.php on line 10

Require_once ' user_service.class.php ';

$admin _id=$_post[' admin_id '];
$admin _password=$_post[' Admin_password '];

$userService =new UserService ();
if ($name = $userService->checkuser ($admin _id, $admin _password)) {

Header ("Location:manage.php?name= $admin _id");

Exit
}else{

Header ("Location:login.php?error=1");
Exit

}
?> This piece of code front-end No problem is performed to the header appears problem
This is user_service.class.php.
Require_once ' sqlhelper.class.php ';
Require_once ' user.class.php ';
Class userservice{


Provides a way to obtain an account information based on the username name
Public Function Getuserbyname ($name) {

$sql = "SELECT * from user where name= '". $name. "'";

$sqlHelper = new SqlHelper ();

$arr = $sqlHelper->dql2 ($sql);

$sqlHelper->close_conn ();

return $arr;//
}
Provides a way to verify that a user is legitimate

Public Function CheckUser ($name, $password) {


$sql = "Select password, name from user where Name= '". $name. "'";
Create a SqlHelper object
$sqlHelper =new sqlHelper ();
$res = $sqlHelper->dql ($sql);
if ($row =mysql_fetch_assoc ($res)) {
Comparison of passwords
if ($password = = $row [' password ']) {
return $row [' name '];

}

}
Mysql_free_result ($res);
$sqlHelper->close_conn ();
Return "";
}
Public Function Genggpassword ($name, $newpassword) {

$sql = "Update user set password= '". $newpassword. "' Where Name= '". $name. "'";

$sqlHelper =new sqlHelper ();

$res = $sqlHelper->dql ($sql);

Mysql_free_result ($res);
$sqlHelper->close_conn ();
}
}
?>
sqlhelper.class.php Code
Tool class
Class sqlhelper{

Public $host = "localhost";
Public $user = "root";
Public $password = "123456";
Public $db = "Bishe";
public $conn;
Public Function SqlHelper () {

$this->conn=mysql_connect ("localhost", "root", "123456") or Die ("123". Mysql_errno ());

if (! $this->conn) {
Die ("Connection Failed". Mysql_errno ());
}
mysql_query ("Set names UTF8");
mysql_select_db ($this->db, $this->conn);

}

Public Function Dql ($sql) {

$res =mysql_query ($sql, $this->conn) or Die (Mysql_errno ());

return $res;
}
Public Function Dql2 ($sql) {

$res =mysql_query ($sql, $this->conn) or Die ("Error! ". Mysql_errno ());

$arr =mysql_fetch_array ($res, $this->conn);
return $arr;
/*echo $arr [0], $arr [' 1 '];
$result = mysql_query ("SELECT * from user where name= ' Xiaowang '");

while ($row = Mysql_fetch_array ($result, mysql_num)) {
printf ("ID:%s Name:%s", $row [0], $row [1]);
}

Mysql_free_result ($result);
return $row; */
}
Public Function Dql2 ($sql) {
$res =mysql_query ($sql, $this->conn) or Die (Mysql_errno ());

return $res;
//}
Delete?
Public function DML ($sql) {
$b =mysql_query ($sql, $this->conn);
if (! $b) {
Return 0;//failed
;
}else {
if (Mysql_affected_rows ($this->conn) >0) {
Return 1;//indicates execution OK
}else {
Return 2;//indicates no row received impact
}
}

}


Public Function Close_conn () {
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.