1.連接數(shù)據(jù)庫(kù):
$_connectSource = mysql_connect('數(shù)據(jù)庫(kù)地址', '數(shù)據(jù)庫(kù)賬號(hào)','數(shù)據(jù)庫(kù)密碼');
2.選在數(shù)據(jù)庫(kù):
mysql_select_db('數(shù)據(jù)庫(kù)名稱','$_connectSource');
3.設(shè)置字符集
mysql_query("set names UTF8",$_connectSource);
4.查詢數(shù)據(jù)
$sql="select*from users where username = '$username'";
var_dump($sql);
$result= mysql_query($sql,$connect);
? if(!$result){
? returnResponse::show(100,'賬號(hào)不存在');
}
$rs= mysql_fetch_assoc($result);
if(is_array($rs)){
? ? ?if($password==$rs['password']){
? ? ? ?returnResponse::show(0,'登錄成功',$rs);
? ? ? }else{
? ? ?returnResponse::show(100,'賬號(hào)密碼錯(cuò)誤');
? ? ?}
}