当前位置:首页 > 开发教程 > php教程 >

打造简单的PHP&MYSQL留言板

时间:2013-04-24 21:39 来源:网络整理 作者:采集侠 收藏

8、updatepost(修改提交页) ?php require_once('conn.php'); $username = $_POST['name']; $info = $_POST['info']; $id = $_GET['id']; //echo $id; $sql = "update lo set username= '".$username."',info='".$info."' wherescriptalert('修改成功!');loc

8、updatepost(修改提交页)

<php
require_once('conn.php');

$username = $_POST['name'];
$info = $_POST['info'];
$id = $_GET['id'];
//echo $id;

$sql = "update lo set username= '".$username."',info='".$info."' where<script>alert('修改成功!');location.href='index.php';</script>";
>

9、delete.php(删除留言页)

<php
session_start();
require_once('conn.php');

$id=$_GET['id'];

if($_SESSION["key"]==1)
{
$sql = "delete from lo where<script>location.href='index.php'</script>";
}
else
{
header('location:index.php');
}
>

10、admin.php(管理登录页)

<php
require_once('conn.php');
require_once('header.php');
>

<div>
    <form method="post" action="adminpost.php">
    <h1>管理员登录</h1>
        <p>姓名 : <input type="text" size="20" />&nbsp;</p>
        <p>密码 : <input type="password" size="20" />&nbsp;</p>
        <p><input type="submit" value="管理员登录" /></p>
        <p>银子留言板 Version 1.0</p>
    </form>
</div>

11、adminpost.php(管理验证页)

<php
session_start();
require_once('conn.php');

$name = $_POST['name'];
$password = $_POST['password'];

$sql = "select * from admin where";
$result = mysql_query($sql);
$num = mysql_num_rows($result);

if (strrpos($name,"<")!==false || strrpos($name,">")!==false||strrpos($name,"@")!==false||strrpos($name,"\"")!==false||strrpos($name,"'")!==false||strrpos($name,"_")!==false)
{
    echo "<script>alert('不能有特殊字符!');location.href='admin.php';</script>";
}

if($num)
{//如果用户存在,就检查密码是否正确
    $rs = mysql_fetch_array($result);
    if($rs[2]!=$password)
    {
        echo "<script>alert('密码不正确,请确认后输入!');location.href='admin.php';</script>";
    }
    else
    {//用户名,密码都正确,注册SESSION变量,然后跳转到首页
        $_SESSION["key"]=1;
        echo "<script>alert('登录成功!');location.href='index.php';</script>";
    }
}
else
{//如果没有这个用户
    echo "<script>alert('没有这个用户,请确认后输入!');location.href='admin.php';</script>";
}
>

12、adminexit.php(退出管理页)

<php
session_start();
$_SESSION["key"] = 0;//使SESSION不为1,0为游客,1为管理员

header('location:index.php');
>

只是些基本的东东,像MD5加密,UBB,表情图片,添加管理员账号,回复留言(-_!!)等我都没加上去,有兴趣的同学可以完善下,不足的地方请指出^_^

管理员账号:wuleying  密码:123456


php教程阅读排行

最新文章