php实战第十一天
这里是HTML模板
[html]
瀑布流记事本安装包
瀑布流记事本安装包
下面是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 "";
/*
*/
?>
//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 "";
/*
*/
?>
下一篇: PHP实现获取图片颜色值的方法