php提交留言去数据库 php无数据库留言板

不用数据库 编写一个PHP留言板 提交后 在页面中显示留言内容 留言时间等我有一个这样的程序 , 以前我的个人博客 。
但在跟你说数据库之前,望你理解一下什么是数据库?如果你说完全不适用数据库,是不能做到你这样的功能的!我是用文本充当数据库 , 做为保存机制 。然后通过自己定义的函数来增删读改该文件的操作 。
表面上看来,你不需要安装任何数据库 , 但要仔细去看看 , 其实自己已经实现了一个数据库,就是没有专业的数据库功能那么强大 , 安全及优化性能没有那么高罢了 。
简单的来说数据库,就是这样的原理 。
我现在用的是办公室的电脑没有装FLASH插件 , 所以不能上传 。你要是要的话,留下邮箱 , 我给你发过去,我邮箱中有 。
下边给你一段,我自己的数据库格式
1|locksepace|lt;spangt;lt;/spangt;|locksepace|2|locksepace|August 31, 2013, 12:50 am|locksepace|1
用|locksepace|分解,你说的时间 , 内容,包括访客IP,等等信息都可包涵 。
哎,为了你,我刚刚安装了一个FLASH插件 , 上传上来吧给你!
效果图
如何用php做出登陆注册留言板登录页:login.php
?php
include("conn.php");
$username=$_POST['name'];
$password=$_POST['password'];
$yanzheng=$_POST['yanzheng'];
if(isset($_POST['submit']))
{
$sql=("select username,password from member where username='$username' and password='$password'") or die("sql语句执行失败");
【php提交留言去数据库 php无数据库留言板】//print_r($sql);
$ar=mysql_query($sql);
if($ar)
{
if($row=mysql_fetch_array($ar))
{
session_start();
if($_POST["yanzheng"])
{
if($yanzheng!=$_session[pic]||$yanzheng=="")
{
echo "验证码输入有误";
exit;
}
if($yanzheng==$_session[pic])
{
header("location:index.php");
}
}
}
else
{
echo "用户名或密码错误";
}
}
}
?
form action="login.php" method="post"
table border=1 align=center width=500 height=300 bgColor=#DFFFDF bordercolor=#fffbec
tr
td colspan=2 align=center用户登录/td
/tr
tr
td用户姓名:/td
tdinput type="text" name="name" id="name"//td
/tr
tr
td用户密码:/td
tdinput type="password" name="password" id="password"//td
/tr
tr
td验证码:/td
tdinput type="text" name="yanzheng" id="yanzheng"/
img src="/images/defaultpic.gif"/img
/td
/tr
tr
td colspan=3 align=center
input type="submit" name="submit" value="https://www.04ip.com/post/登录"/
input type="reset" name="reset" value="https://www.04ip.com/post/重置"/
a href="https://www.04ip.com/post/register.php"注册/a
/td
/tr
/table
/form
注册页:register.php
?php
include("conn.php");
if(isset($_POST['submit'])$_POST['submit']) {
if($_POST['username']=='')
{
echo "用户名不能为空";
exit();
}
if($_POST['password']=='')
{
echo "密码不能为空";
exit();
}
if($_POST['realpass']!=$_POST['password'])
{
echo "两次密码输入不一致";
exit();
}
$sql="insert into member(username,real_name,password,email,headimg) values('$_POST[username]','$_POST[username]','$_POST[password]','$_POST[email]','')";
$ar=mysql_query($sql);
if($ar)
{
header("location:index.php");
}
else
{
echo mysql_error();
}
}

推荐阅读