需要自己创建数据库。具体可以查看下面代码。
登陆页面:
<?
include_once ("conn.php");
//登录部分
if($_POST[button3]==true){
$sqlstr=mysql_query("select usernc from tb_user where usernc='".$_POST[usernc]."' and
userpwd='".$_POST[pwd]."'",$conn);
$sql=mysql_fetch_array($sqlstr);
if ($sql==false)
{
echo "<script>alert('用户名或密码错误!');history.back();</script>";
exit;
}
else
{
if ($_SESSION["unc"]!="")
{
session_unregister("unc");
}
session_register("unc");
$_SESSION["unc"]=$_POST[usernc];
echo "登录成功!";
/* echo "<script>alert('登陆成功!');history.back();</script>";
*/
}
}
echo "登录用户为:".$_SESSION["unc"];
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />