来自经典的打造简单的PHP&MYSQL留言板第1/4页
6、input.php(插入留言)
<?php
require_once("conn.php");
$username = $_post['name'];
$sex = $_post['sex'];
$qq = $_post['qq'];
$email = $_post['email'];
$info = $_post['info'];
if (strrpos($username,"<")!==false || strrpos($username,">")!==false||strrpos($username,"@")!==false||strrpos($username,"\"")!==false||strrpos($username,"'")!==false||strrpos($username,"_")!==false)
{
echo "<script>alert('名称不能有特殊字符!');location.href='post.php';</script>";
exit();
}
if (!ereg("^[0-9]{0,}$",$qq))//用正则检查qq格式
{
echo "<script>alert('oicq信息有错误!必须是数字!');location.href='post.php';</script>";
exit();
}
if($email)
{//如果填写了邮箱就用正则检查邮箱格式
if (!ereg("^[a-za-z0-9_\-\.]+@[a-za-z0-9\-]+\.[a-za-z0-9\-\.]+$",$email))
{
echo "<script>alert('email格式不正确!');location.href='post.php';</script>";
exit();
}
}
if(!$username)
{
echo "<script>alert('名称不能为空哦!');location.href='post.php';</script>";
exit();
}
elseif(!$info)
{
echo "<script>alert('留言不能为空哦!');location.href='post.php';</script>";
exit();
}
else
{
$ip = getenv('remote_addr');//获取客户端ip地址
$sql = "insert into lo (username,sex,qq,email,info,ip,submit_time) values ('$username','$sex','$qq','$email','$info','$ip',now())";
$result = mysql_query($sql);
mysql_close();
echo "<script>alert('提交成功!返回首页');location.href='index.php';</script>";
}
?>
7、update.php(修改留言页)
<?php
session_start();
require_once('conn.php');
require_once('header.php');
if($_session["key"]==1)
{
$id = $_get['id'];
$sql = "select * from lo where id= ".$id;
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
?>
<div id="update">
<form action="updatepost.php?wuleying&id=<?= $row[0] ?>" method="post">
<h1>修改留言</h1>
<p>姓名:<input type="text" value="<?= $row[1]?>" name="name" class="y"></input></p>
<p>留言:</p>
<p><textarea name="info" rows="5" cols="35"><?= $row[5] ?></textarea></p>
<p class="cen"><input type="submit" value="偶要修改" /></p>
<p class="cen1">银子留言板 version 1.0</p>
</form>
<div>
<?php
}
else
{
header('location:index.php');
}
?>
3
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
网安追踪流程
1.不用代理网民发帖流程:发帖人 → ISP → 服务器托管商 → 服务器网警追踪流程:网监 → 服务器IP →...
[阅读全文]
-
-
-
HTTP状态码大全
转自:https://www.cnblogs.com/lxinxuan/archive/2009/10/22/1...
[阅读全文]
-
-
-
-
网友评论