这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。
<center>
<p> </p>
<p> </p>
<form name="form1" method="post" action="login_cl.php">
<table width="500" height="241" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td colspan="2" bgcolor="#999999">会员登陆界面 (login.php)|<a href="index.php">返回</a> </td>
</tr>
<tr bgcolor="#CCCCCC">
<td width="137" align="center">用户:</td>
<td width="363"><input name="yd631_name" type="text" id="yd631_name"></td>
</tr>
<tr bgcolor="#D9D9D9">
<td align="center">密码:</td>
<td><input name="yd631_pws" type="password" id="yd631_pws"></td>
</tr>
<tr align="center" bgcolor="#CCCCCC">
<td colspan="2"><input type="submit" name="Submit" value="提交">
<input type="reset" name="submit" value="重置">
</td>
</tr>
</table>
</form>
<p> </p>
</center>
登陆的php处理代码
include("config.php");
?>
<?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文件。
<?php
//常规参数设置
$servername="localhost"; //主机名
$sqlservername="root"; //mysql数据库用户名
$sqlserverpws="yd631"; //mysql数据库密码
$sqlname="yd631_user"; //数据库名
$sqltable="yd631_users"; //username表名
$admin_name="yd631"; //管理员用户名
$admin_pws="yd631"; //管理员密码
?>