先看看效果图
创建前文件界面
创建配置文件后界面,会提示不能重复安装
下面就上代码吧,html界面的代码就不上了,直接上PHP代码吧
<?php <BR>/* <BR>FILE:install.php <BR>Author:www.5dkx.com <BR>DATE:2010-3-29 <BR>DONE:安装配置文件 <BR>*/ <BR>if($_POST[mysubmit]) <BR>{ <BR>$host = $_POST[hostname]; <BR>$user = $_POST[user]; <BR>$passwd = $_POST[passwd]; <BR>$dbname = $_POST[dbname]; <BR>$siteurl = "http://".$_POST[siteurl]; <BR>$sitekeyword = $_POST[sitekeyword]; <BR>$sitedescription = $_POST[sitedescription]; <BR>$sitename = $_POST[sitename]; <BR>if(!file_exists("install_locak.txt")) <BR>{ <BR>$fp = fopen("./include/config.func.php","w+"); <BR>if(flock($fp,LOCK_EX)) <BR>{ <BR>fwrite($fp,"<"."?php\r\n"); <BR>fwrite($fp,"\$host=\"$host\";\r\n"); <BR>fwrite($fp,"\$user=\"$user\";\r\n"); <BR>fwrite($fp,"\$passwd=\"$passwd\";\r\n"); <BR>fwrite($fp,"\$dbname=\"$dbname\";\r\n"); <BR>fwrite($fp,"\$sitename=\"$sitename\";\r\n"); <BR>fwrite($fp,"\$siteurl=\"$siteurl\";\r\n"); <BR>fwrite($fp,"\$sitekeyword=\"$sitekeyword\";\r\n"); <BR>fwrite($fp,"\$sitedescription=\"$sitedescription\";\r\n"); <BR>$tmp = "\$conn = mysql_connect(\$host,\$user,\$passwd)or die(mysql_error());\r\n"; <BR>fwrit<strong>+本文来源gao@daima#com搞(%代@#码网</strong><pre>搞代gaodaima码
e($fp,$tmp);
$tmp =”mysql_query(\”set names ‘gbk’\”)or die(\”设置字符库失败!\”);\r\n”;
fwrite($fp,$tmp);
$tmp =”mysql_select_db(\$dbname,\$conn)or die(\”连接数据库失败!\”);\r\n”;
fwrite($fp,$tmp);
fwrite($fp,”?>\r\n”);
flock($fp,LOCK_UN);
echo “文件配置成功!
“;
echo “<script language=\”javascript\”>window.location.href=\”install2.php\”;</script>”;
}
else
{
echo “can’t lock the file!
“;
}
fclose($fp);
$fins = fopen(“install_lock.txt”,”w”);
fclose($fins);
}
else
{
echo “install_locak.txt已经存在,要想重新安装请删除此文件!
“;
}
}
?>