Create a configuration file and use PHP to write your BLOG System 2. First look at the file interface before the creation of the configuration file after the interface, will prompt that you can not install the following code again, the html interface code will not be available, directly on the PHP code copy first look
File interface before creation
After the configuration file is created, the system prompts that the installation cannot be repeated.
Let's go to the code below. the code on the html interface is no longer available. just go to the PHP code.
The code is as follows:
/*
FILE: install. php
Author: www.5dkx.com
DATE: 2010-3-29
DONE: install the 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, "<"."? Php \ r \ n ");
Fwrite ($ fp, "\ $ host = \" $ host \ "; \ r \ n ");
Fwrite ($ fp, "\ $ user = \" $ user \ "; \ r \ n ");
Fwrite ($ fp, "\ $ passwd = \" $ passwd \ "; \ r \ n ");
Fwrite ($ fp, "\ $ dbname = \" $ dbname \ "; \ r \ n ");
Fwrite ($ fp, "\ $ sitename = \" $ sitename \ "; \ r \ n ");
Fwrite ($ fp, "\ $ siteurl = \" $ siteurl \ "; \ r \ n ");
Fwrite ($ fp, "\ $ sitekeyword = \" $ sitekeyword \ "; \ r \ n ");
Fwrite ($ fp, "\ $ sitedescription = \" $ sitedescription \ "; \ r \ n ");
$ Tmp = "\ $ conn = mysql_connect (\ $ host, \ $ user, \ $ passwd) or die (mysql_error (); \ r \ n ";
Fwrite ($ fp, $ tmp );
$ Tmp = "mysql_query (\" set names 'gbk' \ ") or die (\" failed to set the character Library! \ "); \ R \ n ";
Fwrite ($ fp, $ tmp );
$ Tmp = "mysql_select_db (\ $ dbname, \ $ conn) or die (\" failed to connect to the database! \ "); \ R \ n ";
Fwrite ($ fp, $ tmp );
Fwrite ($ fp, "?> \ R \ n ");
Flock ($ fp, LOCK_UN );
Echo "file configured successfully!
";
Echo"