登录页面代码(login.php):
<?php
include("../com/conn.php");
if($_POST[sub]){
$sql ="select * from cp_userlist where username='".$_POST[user]."' and password='".$_POST[pwd]."'";
$query=mysql_query($sql);
$row = mysql_fetch_array($query);
if($row){
$_SESSION["name"]=$_POST[user];
echo "<script>window.location.href='http://wyl072.blog.163.com/blog/index.php';</script>";
}
else {
echo "<script>alert(\"用户名或者密码错误!\");</script>";
echo "<script>window.location.href='http://wyl072.blog.163.com/blog/login.php'</script>";
}
} else {
}
?>
<form action="login.php" method="post">
用户名称:<input name="user" type="text" /><br />
用户密码:<input name="pwd" type="password" /><br />
<input type="submit" name="sub" value="登录"/><input type="reset" value="重置" />
</form>
用户的退出页面(top.php):
<script language=JavaScript>
function logout(){
if (confirm("您确定要退出控制面板吗?"))
{
top.location = "b.php";
}
return false;
}
</script>
<a href="http://wyl072.blog.163.com/blog/#" target="_self" onClick="logout();">安全退出</a>
跳转到 b.php
b.php 中执行的代码:
<?php
include("../com/conn.php");
session_destroy();
echo "<script>window.location.href='http://wyl072.blog.163.com/blog/login.php'</script>";
?>
配置文件conn.php 代码:
<?php
session_start();
error_reporting(0);
$con = mysql_connect("localhost","root","");
mysql_select_db('company',$con);
mysql_query("set names 'gb2312'");
?>
跳转到
配置文件conn.php 代码: