</head>
<body>
<?php
session_start();
require("config.auth.php");
if ($_POST[submit]) {
$sql="select * from userinfo where username = '$_POST[username]' and password =
'$_POST[password]'";
$result=mysql_query($sql);
$numrows=mysql_num_rows($result);
if ($numrows == 1) {
$row=mysql_fetch_assoc($result);
$_SESSION[username]=$row[username];
//echo $_SESSION[username];
echo "<script>alert('登陆成功!');window.location.href='left.php';</script>";
}else {
echo "<script>alert('登陆失败!');window.location.href=\'#\'" /script>";
}
}else {
echo "<script>alert('请通过正确途径登陆!');window.location.href=\'#\'" /script>";
}
mysql_free_result($result);
mysql_close($conn);
?>
</body>
</html>
4,logout.php
代码示例
:
<!DOCTYPE
html
PUBLIC
"-//W3C//DTD
XHTML
1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登陆系统_www.jbxue.com</title>
</head>
<body>
<?php
session_start();
unset($_SESSION[username]);
session_destroy();
echo "<script>alert('注销成功!');window.location.href=\'#\'" /script>";
?>
</body>
</html>