Submitted by 爱得 on 2009, February 21, 5:48 PM
删除......
此留言本程序为整合,用于学习之用途,其它不限.
附1:css.css
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#666666;
background:#fff;
text-align:center;
}
* {
margin:0;
padding:0;
}
a {
color:#1E7ACE;
text-decoration:none;
}
a:hover {
color:#000;
text-decoration:underline;
}
h3 {
font-size:14px;
font-weight:bold;
}
» 阅读全文
Tags: php
PHP相关 | 评论:0
| Trackbacks:0
| 阅读:410
Submitted by 爱得 on 2009, February 21, 5:47 PM
删除......
此留言本程序为整合,用于学习之用途,其它不限.
第八节:anyone.php
这里我只做了info也就是留言内容中的内容可修改,你可以自己修改成全部可改。
<?
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>爱得留言本</title>
<link rel="stylesheet" href="css.css" type="text/css" media="all" />
</head>
<body>
<div id="formwrapper">
<h3>修改留言</h3>
<?
if($_SESSION['admin']=="OK")
{
require('config.php');
$conn=mysql_connect($host,$user,$password);
mysql_select_db($db);
mysql_query("set names GB2312");
$exec="select * from gbook where id=".$_GET['id'];
$result=mysql_query($exec);
$rs=mysql_fetch_object($result);
$name=$rs->name;
$email=$rs->email;
$home=$rs->home;
$title=$rs->title;
$info=$rs->info;
$id=$rs->id;
?>
» 阅读全文
Tags: php
PHP相关 | 评论:0
| Trackbacks:0
| 阅读:353
Submitted by 爱得 on 2009, February 21, 5:47 PM
删除......
此留言本程序为整合,用于学习之用途,其它不限.
第六节:check.php
判断用户名和密码的正确性。
<?
require('config.php');
session_start();
$admin_name=$_POST['admin_name'];
$admin_password=$_POST['password'];
$conn=mysql_connect($host,$user,$password);
mysql_select_db($db);
mysql_query("set names GB2312");
$exec="select password from users where admin_name='$admin_name'";
$result=mysql_query($exec);
$num=mysql_num_rows($result);
if ($rs=@mysql_fetch_object($result))
{ if ($rs->password==$admin_password)
{$_SESSION['admin']="OK";
header("location:admin_index.php");
}
else echo"密码不正确,请<a href='login.php'>返回</a>";
}
else echo"用户名不正确,请<a href='login.php'>返回</a>";
mysql_close();
?>
» 阅读全文
Tags: php
PHP相关 | 评论:0
| Trackbacks:0
| 阅读:399
Submitted by 爱得 on 2009, February 21, 5:46 PM
删除......
此留言本程序为整合,用于学习之用途,其它不限.
第四节:update.php
根据用户在index.php提交的内容存到表gbook中,
<?php
function getip() {
$IP=getenv('REMOTE_ADDR');
$IP_ = getenv('HTTP_X_FORWARDED_FOR');
if (($IP_ != "") && ($IP_ != "unknown")) $IP=$IP_;
return $IP;
}
require('config.php');
$name=$_POST['post_name']; //把获得的内容放到$name中
$email=$_POST['post_email'];
$home=$_POST['post_home'];
$ip=getip();
$title=$_POST['post_title'];
$info=$_POST['post_info'];
$time=date('Y-m-d H:i:s');
$conn=mysql_connect($host,$user,$password); //连接sql服务器
mysql_query("set names GB2312");
mysql_select_db($db); //连接数据库
$exec="insert into gbook (name,email,home,ip,title,info,time)values('$name','$email','$home','$ip','$title','$info','$time')";
$result=mysql_query($exec);//插入留言内容到表gbook中的相应地方。
mysql_close();
header("location:index.php"); //完成后返回到index.php
?>
» 阅读全文
Tags: php
PHP相关 | 评论:0
| Trackbacks:0
| 阅读:250
Submitted by 爱得 on 2009, February 21, 5:45 PM
删除......
此留言本程序为整合,用于学习之用途,其它不限.
第三节:取=读 index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>爱得留言本</title>
<link rel="stylesheet" href="css.css" type="text/css" media="all" />
<script type="text/javascript">
function check_message(){
if(window.document.leave.post_name.value==""){
alert("请填写用户名.");
document.leave.post_name.focus();
return false;}
if(document.leave.post_title.value==""){
alert("请填写留言标题.");
document.leave.post_title.focus();
return false;}
if(document.leave.post_info.value==""){
alert("请填写留言内容.");
document.leave.post_info.focus();
return false;}
return true;
}
</script>
</head>
<body>
<div id="formwrapper">
<h3><a class="del" href="login.php">管理</a>用户留言内容</h3>
» 阅读全文
Tags: php
PHP相关 | 评论:0
| Trackbacks:0
| 阅读:462
Submitted by 爱得 on 2009, February 21, 5:42 PM
删除......
此留言本程序为整合,用于学习之用途,其它不限.
规划:
这个就是最后做成的样子,先看下数据如何安排:
首先要有一个表放留言内容的,于是创建表gbook ,然后在这个表里设定 name、email、home、title、info、和 id 分别存取各内容。
这个要有管理功能,所以再创建一个表users 里面只有id、admin_name、password。
第一节:config.php
<?php
$host ="localhost"; //MYSQL数据库地址,通常为IP地址或者网址,请问一下你的空间提供商
$db ="data"; //所使用MYSQL数据库名称
$user ="root"; //MYSQL数据库登陆账号
$password =" "; //MYSQL数据库登陆密码
?>
按提示填好,这个文件应该不难。
» 阅读全文
Tags: php
PHP相关 | 评论:0
| Trackbacks:0
| 阅读:415