首页 > 开发 > PHP > 正文

PHP+MySQL 制作简单的留言本

2024-05-04 22:10:33
字体:
来源:转载
供稿:网友

 

留言显示页面:比上一个例子增加了分页和留言回复的功能

主要代码:
install/index.php:程序安装页面
代码如下:
<?php
if($_GET["action"]!=1)
{
?>
<form method="post" action="index.php?action=1">
<table border="1">
<tr>
<td>MySQL主机名:</td>
<td><input type="text" name="host" value="localhost"></td>
</tr>
<tr>
<td>MySQL用户名:</td>
<td><input type="text" name="user" value="root"></td>
</tr>
<tr>
<td>MySQL密码:</td>
<td><input type="password" name="password" value=""></td>
</tr>
<tr>
<td>数据库名称:</td>
<td><input type="text" name="database" value="ruizhi_messageboard"></td>
</tr>
<tr>
<td>留言本每页记录数:</td>
<td><input type="text" name="pagenum" value="10"></td>
</tr>
<tr>
<td>管理员账号:</td>
<td><input type="text" name="admin_name" value="admin"></td>
</tr>
<tr>
<td>管理员密码:</td>
<td><input type="text" name="admin_password" value="admin"></td>
</tr>
<tr>
<td>留言本标题:</td>
<td><input type="text" name="boardname" value="RUIZHINET留言本"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="确定安装"> <input type="button" name="submit" value="关闭页面" onclick="window.close()"></td>
<td></td>
</tr>
</table>
</form>
<?php
}else{
@set_time_limit(1000);
$lockfile = "install.lock";
$host="localhost";
$user="root";
$password="";
$database="ruizhi_messageboard";
$pagenum=10;
$admin_name="admin";
$admin_password="123456";
$boardname="RUIZHINET留言本";
if($_POST["host"]!=""){
$host=$_POST["host"];
}
if($_POST["user"]!=""){
$user=$_POST["user"];
}
if($_POST["password"]!=""){
$password=$_POST["password"];
}
if($_POST["database"]!=""){
$database=$_POST["database"];
}
if($_POST["pagenum"]!=""){
$pagenum=$_POST["pagenum"];
}
if($_POST["admin_name"]!=""){
$admin_name=$_POST["admin_name"];
}
if($_POST["admin_password"]!=""){
$admin_password=$_POST["admin_password"];
}
if($_POST["boardname"]!=""){
$boardname=$_POST["boardname"];
}
if(file_exists($lockfile)){
exit("已经安装过了,如果要重新安装请先删除install/install.lock");

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表