Install.php simple production
recently wrote some source code, the summer CMS article management system, summer PHP message book, summer PHP additions and deletions modification procedures, summer PHP voting system and so on, these are for the convenience of the novice friends of PHP learning to use, so direct export of MySQL data Library, put it in the root directory, in fact, this is not a very good experience for beginners, many PHP novice friends do not know how to import MySQL database, not already, and later devoted to writing a chapter on "how to use tools to import MySQL database".
if we use open source PHP programs such as dream, you will feel that the source code is easy to use, because there is an installation source file, through which the source, automatic MySQL database import and configuration installation, even if you do not understand the PHP program, installation is also very simple, right and used, In the case of learning PHP, this is a very necessary function, before Ben Bo wrote a simple installer, Briefly Talking about the principles of the PHP installer.
downloaded PHP source code, usually in the root directory there will be a install.php file, this is the PHP source of the installation file, if you want to install PHP source code, usually through the "your web site /install.php" path to install, in the installation process, will be required to fill in the MySQL username and Password can be installed successfully according to the requirement.
in fact, we can understand the principle of the installation of PHP program in the installation panel of install.php. Through install.php files, we will require us to fill in the host address, MySQL username, MySQL password, MySQL database, all of which are basically these. As for the more complex, it may require some What can be written, let's look at the simplest principle, and know the basic information that you need to fill in when you install it. It's not hard to think about it, which is to generate a config.php - like file, which can connect the MySQL database through this config.php configuration file, and then pass the PH The P SQL statement creates the MySQL table that it filled out, and the simplest install.php installation applet is made.
below to see a simple source code for install.php installation files:
PHP code
[code].Lt; HTML xmlns=.quot. Tf-8.quot; /.gt;
.Lt; title.gt; PHP installation small program.Lt; /title.gt;
.Lt; /head.gt;
> {> > > Post.quot;.Gt;
host address:.Lt; input type=.quot; text.quot; name=.quot; host.quot; value=.quot; localhost.quot;.Gt. Uot; password.quot; name=.quot; psw.quot; value=.quot;.Quot;.Gt;.Lt; br.gt;
.
.Lt; /form.gt;
.Lt; PHP
else
$lockfile = {
}; .amp;.Amp; $_POST.#91;'db'.#93; =.quot;.Quot;)
{
$host=$_POST.#91;'host'.#93;
$user=$_POST.#91;;
Exit (.Quot; already installed, if you want to reinstall, delete install.lock.quot first;);
}
$conn=mysql_connect ($host, $user, $psw);
{} / >; R / > $sql_create_db=.quot; Create DATABASE `.quot;.$db..Quot; `.quot;
$sql_create_table_blog=.quot; Create TABLE `blog`.`blog`. IMARY KEY (`id`)
ENGINE = MYISAM.quot;
mysql_query ($sql_drop_db, $conn);
>; > $config_strings=.quot;.Lt;? Php\n.quot;
$config_strings.=.quot; \$host=\.quot;.Quot;.$host..Quot; \.quot; \n.quot; $config_strings.=.quot;
; T;; \n.quot;;
$config_strings.=.quot; \$db=\.quot;.Quot;.$db..Quot; \.quot; \n.quot;
$config_strings.=.quot; \$conn=mysql_connect / >;; Uot;.Gt;.Quot;
$fp=fopen ($config_file,.Quot; wb.quot;);
fwrite.
.Lt; /body.gt;
.Lt; /html.gt; [/code]
: for some large PHP source code, the most core principles are basically the same. For PHP beginners, it is not necessary to understand the complex PHP installer, and master the simple installation files of the PHP source first, The complex is not difficult. By running the program, the PHP configuration file config.php is automatically generated, which is a file that is communicated with the MySQL database, and a install.lock file is generated. This is a file that determines whether it has been successfully installed, and a new one in the MySQL data base can be built manually. Add the MySQL database.