Make PHP Installer

Source: Internet
Author: User
Tags button type create database file permissions
First create two PHP files one is install.php the other is config.php which config.php is empty file
install.php contents are as follows: <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <body> <?php   $files = "config.php";     if (!is_writable ($files))    // is_writable () Check whether the file is writable to determine file permissions   {  echo " Not writable ";  }else{  echo "writable"  }      if (isset ($_post[' Install '))   {   $conf Ig_str= "<?php";    $config _str.= "\ n";    $config _str.= ' $mysql _host = '. $_post[localhost]. ';    $config _str.= "\ n";    $config _str.= ' $mysql _user = '. $_post[username]. ';    $config _str.= "\ n";      $config _str.= ' $mysql _pass = '. $_post[password]. ';    $config _str.= "\ n";      $config _str.= ' $mysql _dbname = '. $_post[mysql_db]. ';    $config _str.= "\ n";      $config _str.= ' $mysql _table = '. $_post[table]. ';    $config _str.= "\ n";      $config _str.= "?>";         $ff =fopen ($files, "w+");  //File operation open a file or create a new   fwrite ($FF, $confIG_STR);  //  file operations   write content to file      include_once ("config.php");   if (!@ $link =mysql_connect ($mysql _host, $mysql _user, $mysql _pass))  //Determine if the connection database is successful   {   echo failed to connect to the database. Previous page <a href=install.php> </a> ";   }else{  mysql_query ("CREATE database ' $mysql _dbname '");  //  Creating Databases    mysql_select_db ($mysql _dbname);    $sql _query[]= "CREATE TABLE   ' $mysql _dbname '". $mysql _table. " QQQ ' (                    ' id ' INT (Ten) not NULL auto_increment, &nbs P                   ' AAA ' VARCHAR (MB) not NULL,                     ' xxx ' VARCHAR (MB) not NULL,             &NBSP ;       PRIMARY KEY (  ' id ')                   ENGINE = INNODB";    $sql _query[]= "CREATE TABLE   ' $mysql _dbname '". $mysql _table. " SSSs ' (                    ' id ' INT (Ten) not NULL auto_increment, &NB Sp                   ' AAA ' VARCHAR (MB) not NULL,                     ' xxx ' VARCHAR (MB) not NULL,             &NBSP ;       PRIMARY KEY (  ' id ')                   ENGINE = INNODB ";  //  This can be directly from their own phpmyadmin inside production in advance foreach ($sql _query as $val) {mysql_query ($val);}    echo "Success";    rename ("install.php", "Install.lock");  //File Rename the file or delete the install.php configuration file at this time to improve security   }  }
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.