Home  >  Article  >  Backend Development  >  Create configuration files and write your own BLOG system using PHP 2_PHP tutorial

Create configuration files and write your own BLOG system using PHP 2_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:39:221084browse

Let’s take a look at the renderings first

Pre-creation file interface

After creating the configuration file, the interface will prompt that repeated installation is not possible

Let’s enter the code below. The code for the html interface will not be uploaded. Just enter the PHP code directly

Copy the code The code is as follows:

/*
FILE:install.php
Author:www.5dkx.com
DATE:2010-3-29
DONE: Install configuration file
*/
if($_POST[mysubmit])
{
$host = $_POST[hostname];
$user = $_POST[user];
$passwd = $_POST[passwd];
$dbname = $_POST[dbname];
$siteurl = "http://".$_POST[siteurl];
$sitekeyword = $_POST[sitekeyword];
$sitedescription = $_POST[sitedescription];
$sitename = $_POST[sitename];
if(!file_exists("install_locak.txt"))
{
$fp = fopen( "./include/config.func.php","w+");
if(flock($fp,LOCK_EX))
{
fwrite($fp,"<"."?phprn ");
fwrite($fp,"$host="$host";rn");
fwrite($fp,"$user="$user";rn");
fwrite( $fp,"$passwd="$passwd";rn");
fwrite($fp,"$dbname="$dbname";rn");
fwrite($fp,"$sitename=" $sitename";rn");
fwrite($fp,"$siteurl="$siteurl";rn");
fwrite($fp,"$sitekeyword="$sitekeyword";rn");
fwrite($fp,"$sitedescription="$sitedescription";rn");
$tmp = "$conn = mysql_connect($host,$user,$passwd)or die(mysql_error()); rn";
fwrite($fp,$tmp);
$tmp ="mysql_query("set names 'gbk'")or die("Failed to set character library!");rn";
fwrite($fp,$tmp);
$tmp ="mysql_select_db($dbname,$conn)or die("Failed to connect to database!");rn";
fwrite($fp,$tmp);
fwrite($fp,"?>rn");
flock($fp,LOCK_UN);
echo "File configuration successful!
";
echo "";


}
else
{
echo "can 't lock the file!
";
}
fclose($fp);
$fins = fopen("install_lock.txt","w");
fclose($ fins);
}
else
{
echo "install_locak.txt already exists, please delete this file if you want to reinstall!
";
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321571.htmlTechArticle First look at the file interface before creating the renderings and the interface after creating the configuration file. It will prompt that repeated installation is not allowed. Next, enter the code. Well, I won’t upload the code for the html interface. Just upload the PHP code and copy it...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn