來(lái)自經(jīng)典的打造簡(jiǎn)單的PHP&MYSQL留言板第3/4頁(yè)
更新時(shí)間:2008年03月31日 13:55:19 作者:
比較簡(jiǎn)單易懂的php+mysql留言板
數(shù)據(jù)庫(kù)結(jié)構(gòu):(庫(kù)名:lyb)
6、input.php(插入留言)
復(fù)制代碼 代碼如下:
<?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信息有錯(cuò)誤!必須是數(shù)字!');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('提交成功!返回首頁(yè)');location.href='index.php';</script>";
}
?>
7、update.php(修改留言頁(yè))
復(fù)制代碼 代碼如下:
<?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');
}
?>
您可能感興趣的文章:
- PHP實(shí)現(xiàn)基本留言板功能原理與步驟詳解
- 使用PHP開(kāi)發(fā)留言板功能
- PHP實(shí)現(xiàn)的簡(jiǎn)單留言板功能示例【基于thinkPHP框架】
- 使用PHP連接數(shù)據(jù)庫(kù)實(shí)現(xiàn)留言板功能的實(shí)例講解(推薦)
- php+Memcached實(shí)現(xiàn)簡(jiǎn)單留言板功能示例
- 簡(jiǎn)單實(shí)現(xiàn)PHP留言板功能
- 基于thinkPHP框架實(shí)現(xiàn)留言板的方法
- PHP結(jié)合Mysql數(shù)據(jù)庫(kù)實(shí)現(xiàn)留言板功能
- php實(shí)現(xiàn)網(wǎng)站留言板功能
- php制作文本式留言板
- php簡(jiǎn)單的留言板與回復(fù)功能具體實(shí)現(xiàn)
- php開(kāi)發(fā)留言板的CRUD(增,刪,改,查)操作
- php xml留言板 xml存儲(chǔ)數(shù)據(jù)的簡(jiǎn)單例子
- 一個(gè)簡(jiǎn)單的PHP&MYSQL留言板源碼
- 一個(gè)可分頁(yè)的基于文本的PHP留言板源碼
- PHP+MySql實(shí)現(xiàn)一個(gè)簡(jiǎn)單的留言板
相關(guān)文章
destoon安裝出現(xiàn)Internal Server Error的解決方法
這篇文章主要介紹了destoon安裝出現(xiàn)Internal Server Error的解決方法,需要的朋友可以參考下2014-06-06Yii2語(yǔ)言國(guó)際化自動(dòng)配置詳解
這篇文章主要介紹了Yii2語(yǔ)言國(guó)際化自動(dòng)配置詳解,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-08-08Yii2.0 RESTful API 基礎(chǔ)配置教程詳解
這篇文章主要介紹了Yii2.0 RESTful API 基礎(chǔ)配置教程,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-12-12php微信公眾號(hào)開(kāi)發(fā)之校園圖書館
這篇文章主要為大家詳細(xì)介紹了php微信公眾號(hào)開(kāi)發(fā)之校園圖書館,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-10-10