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
}
?> 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 '");
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.