发布时间:2015-05-27 19:27:00作者:知识屋
今天学习了做安装包
这里是HTML模板
[html]
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>瀑布流留言板管理系统</title>
<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"></head>
<body>
<div class="container">
<div class="container-fluid">
<div class="row-fluid">
<div class="span4">
<h3>瀑布流记事本安装包</h3>
</div>
</div>
</div>
<form class="form-horizontal" action="install.php" method="post" >
<div class="control-group">
<label class="control-label" for="content">MYSQL主机</label>
<div class="controls">
<input class="span4" type="text" name="m_server" value="localhost" placeholder="mysql数据库的地址">
<span class="help-inline">你的数据库所在IP,一般是localhost</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">数据库用户名</label>
<div class="controls">
<input class="span4" type="text" name="m_userName" value="root" placeholder="mysql数据库登陆用户名">
<span class="help-inline">你的MySQL帐户。</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">数据库密码</label>
<div class="controls">
<input class="span4" type="text" name="m_password" value="1234" placeholder="mysql数据库登陆密码">
<span class="help-inline">你的MySQL密码。</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">数据库名称</label>
<div class="controls">
<input class="span4" type="text" name="m_dbName" value="db_liuyan" placeholder="数据库名称">
<span class="help-inline">你的数据库名称,请先确认此数据库存在。</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">网站的标题</label>
<div class="controls">
<input class="span4" type="text" name="c_title" value="我的瀑布流留言板" placeholder="网站的标题">
<span class="help-inline">设置网站的标题</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">后台登陆用户名</label>
<div class="controls">
<input class="span4" type="text" name="adminUser" value="admin" placeholder="后台登陆用户名">
<span class="help-inline">登陆后台所用的用户名</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">后台登陆密码</label>
<div class="controls">
<input class="span4" type="text" name="adminPassword" value="admin" placeholder="后台登陆密码">
<span class="help-inline">登陆后台所用的密码</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<input class="btn btn-info" type="submit" name="submit" value="安装">
</div>
</div>
</form>
</div>
</body>
<script src="../js/jquery-2.0.1.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>瀑布流留言板管理系统</title>
<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"></head>
<body>
<div class="container">
<div class="container-fluid">
<div class="row-fluid">
<div class="span4">
<h3>瀑布流记事本安装包</h3>
</div>
</div>
</div>
<form class="form-horizontal" action="install.php" method="post" >
<div class="control-group">
<label class="control-label" for="content">MYSQL主机</label>
<div class="controls">
<input class="span4" type="text" name="m_server" value="localhost" placeholder="mysql数据库的地址">
<span class="help-inline">你的数据库所在IP,一般是localhost</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">数据库用户名</label>
<div class="controls">
<input class="span4" type="text" name="m_userName" value="root" placeholder="mysql数据库登陆用户名">
<span class="help-inline">你的MySQL帐户。</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">数据库密码</label>
<div class="controls">
<input class="span4" type="text" name="m_password" value="1234" placeholder="mysql数据库登陆密码">
<span class="help-inline">你的MySQL密码。</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">数据库名称</label>
<div class="controls">
<input class="span4" type="text" name="m_dbName" value="db_liuyan" placeholder="数据库名称">
<span class="help-inline">你的数据库名称,请先确认此数据库存在。</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">网站的标题</label>
<div class="controls">
<input class="span4" type="text" name="c_title" value="我的瀑布流留言板" placeholder="网站的标题">
<span class="help-inline">设置网站的标题</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">后台登陆用户名</label>
<div class="controls">
<input class="span4" type="text" name="adminUser" value="admin" placeholder="后台登陆用户名">
<span class="help-inline">登陆后台所用的用户名</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userName">后台登陆密码</label>
<div class="controls">
<input class="span4" type="text" name="adminPassword" value="admin" placeholder="后台登陆密码">
<span class="help-inline">登陆后台所用的密码</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<input class="btn btn-info" type="submit" name="submit" value="安装">
</div>
</div>
</form>
</div>
</body>
<script src="../js/jquery-2.0.1.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
</html>
下面是php代码
[php]
<?php
//var_dump($_POST);
$server =$_POST['m_server'];
$userName=$_POST['m_userName'];
$password=$_POST['m_password'];
$dbName=$_POST['m_dbName'];
$adminUser=$_POST['adminUser'];
$adminPassword=md5($_POST['adminPassword']);
$title=$_POST['c_title'];
include '../function.php';
$c=config_get('../config.php');
$c['dbServer']=$server;
$c['dbUserName']=$userName;
$c['dbPassword']=$password;
$c['dbName']=$dbName;
$c['title']=$title;
$c['footer']='已经滚动到底部了';
//$c['adminUser']=$adminUser;
//$c['adminPassword']=$adminPassword;
config_set("../config.php",$c);
//var_dump($GLOBALS);
$conn=mysql_connect($server,$userName,$password)or die("mysql连接失败 错误信息:" . mysql_error());
/**
* 选择数据库,如果不存在则自动创建
*/
if(!mysql_select_db($dbName)){
$query='CREATE DATABASE '.$dbName;
$result = mysql_query($query)or die("1Invalid query: " . mysql_error());
if(!$result){
echo "创建数据库失败,请手动创建 {$dbName}";
exit();
}
mysql_select_db($dbName);
}
/**
* 创建data表,用于留言记录
*/
$query="CREATE TABLE IF NOT EXISTS `data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`time` int(10) NOT NULL,
`userName` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`content` text COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=26";
$result = mysql_query($query)or die("创建数据表 'data' 失败 错误信息:" . mysql_error());
/**
* 创建user表,用于用户管理
*/
$query="CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userName` text NOT NULL,
`password` varchar(40) NOT NULL,
`time` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2";
$result = mysql_query($query)or die("创建数据表 'user' 失败 错误信息:" . mysql_error());
//插入user表用户
$query="INSERT INTO `user` (`id`, `userName`, `password`, `time`)
VALUES (1, '{$adminUser}', '{$adminPassword}', 1369417030)";
$result = mysql_query($query);
if (!$result) {
echo ("'user'表,插入数据失败 错误信息:".mysql_error());
}
echo "安装成功";
//header("Localhost: ./admin.php?m=admin&a=index");
//echo "<script>window.location.href='../admin.php?m=admin&a=login';</script>";
/*
*/
?>
<?php
//var_dump($_POST);
$server =$_POST['m_server'];
$userName=$_POST['m_userName'];
$password=$_POST['m_password'];
$dbName=$_POST['m_dbName'];
$adminUser=$_POST['adminUser'];
$adminPassword=md5($_POST['adminPassword']);
$title=$_POST['c_title'];
include '../function.php';
$c=config_get('../config.php');
$c['dbServer']=$server;
$c['dbUserName']=$userName;
$c['dbPassword']=$password;
$c['dbName']=$dbName;
$c['title']=$title;
$c['footer']='已经滚动到底部了';
//$c['adminUser']=$adminUser;
//$c['adminPassword']=$adminPassword;
config_set("../config.php",$c);
//var_dump($GLOBALS);
$conn=mysql_connect($server,$userName,$password)or die("mysql连接失败 错误信息:" . mysql_error());
/**
* 选择数据库,如果不存在则自动创建
*/
if(!mysql_select_db($dbName)){
$query='CREATE DATABASE '.$dbName;
$result = mysql_query($query)or die("1Invalid query: " . mysql_error());
if(!$result){
echo "创建数据库失败,请手动创建 {$dbName}";
exit();
}
mysql_select_db($dbName);
}
/**
* 创建data表,用于留言记录
*/
$query="CREATE TABLE IF NOT EXISTS `data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`time` int(10) NOT NULL,
`userName` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`content` text COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=26";
$result = mysql_query($query)or die("创建数据表 'data' 失败 错误信息:" . mysql_error());
/**
* 创建user表,用于用户管理
*/
$query="CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userName` text NOT NULL,
`password` varchar(40) NOT NULL,
`time` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2";
$result = mysql_query($query)or die("创建数据表 'user' 失败 错误信息:" . mysql_error());
//插入user表用户
$query="INSERT INTO `user` (`id`, `userName`, `password`, `time`)
VALUES (1, '{$adminUser}', '{$adminPassword}', 1369417030)";
$result = mysql_query($query);
if (!$result) {
echo ("'user'表,插入数据失败 错误信息:".mysql_error());
}
echo "安装成功";
//header("Localhost: ./admin.php?m=admin&a=index");
//echo "<script>window.location.href='../admin.php?m=admin&a=login';</script>";
/*
*/
?>
如何对PHP文件进行加密方法 PHP实现加密的几种方式介绍
php生成圆角图片的方法 电脑中php怎么生成圆角图片教程
用PHP构建一个留言本方法步骤 php怎么实现留言板功能
php中三元运算符用法 php中的三元运算符使用说明
php文件如何怎么打开方式介绍 php文件用什么打开方法
PHP怎么插入数据库方法步骤 php编程怎么导入数据库教程
如何安装PHPstorm并配置方法教程 phpstorm安装后要进行哪些配置
PHP 获取远程文件大小的3种解决方法 如何用PHP获取远程大文件的大小
20个实用PHP实例代码 php接口开发实例代码详细介绍
如何架设PHP服务器方法步骤 怎么搭建php服务器简单教程