【www.gdgbn.com--php常用代码】

这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。


 

 


 

 


 

   
     
        会员登陆界面 (login.php)|返回
     
     
        用户:
       
     
     
        密码:
       
     
     
          
         
   
         
     
   
 

 

 


 

登陆的php处理代码

include("config.php");
?>
if(empty($_POST["yd631_name"])){
echo ("<script type="text/javascript"> alert("用户名怎么能是空的呢!");history.go(-1);</script>");
}
if(empty($_POST["yd631_pws"])){
echo ("<script type="text/javascript"> alert("密码也不能是空的!");history.go(-1);</script>");
}
$yd631_name= $_POST["yd631_name"]; //用户名已经记录了
$yd631_pws= $_POST["yd631_pws"]; //密码已经记录了
$db=mysql_connect($servername,$sqlservername,$sqlserverpws);
mysql_select_db($sqlname,$db);
$sql="select * from $sqltable where yd631_name="$yd631_name" and yd631_pws="$yd631_pws"";
$result=mysql_fetch_array(mysql_query($sql));
if(!$result){
echo ("<script type="text/javascript"> alert("用户名或密码不正确!");history.go(-1);</script>");
mysql_close();
exit;
}
if($result["yd631_pass"]=="no"){
 //验证会员是不是被审核通过了
echo ("<script type="text/javascript"> alert("您还没有被审核呢!");history.go(-1);</script>");
}
session_start();
$_SESSION["name"]="$yd631_name";
echo "<script>location.href="yd631.php";</script>";
?>

config文件。

//常规参数设置

$servername="localhost";  //主机名
$sqlservername="root"; //mysql数据库用户名
$sqlserverpws="yd631"; //mysql数据库密码

$sqlname="yd631_user"; //数据库名
$sqltable="yd631_users"; //username表名


$admin_name="yd631";  //管理员用户名
$admin_pws="yd631";   //管理员密码
?>

本文来源:http://www.gdgbn.com/jiaocheng/20596/