Copy codeThe Code is as follows: <? Php
/*************************************** ******
*
* Program name: php fan message board
* Performance: http://www.phpfans.net/guestbook/
*
* Author: I am not a fish
* Email: deng5765@163.com
* Address: http://www.phpfans.net
* Blog: http://www.phpfans.net/space? 2
* Version: v1.0
* Help: http://www.phpfans.net/guestbook/
**************************************** *****/
If (isset ($ _ POST ['submit ']) {
$ Mydbuser = $ _ POST ['m _ root'];
$ Mydbpw = $ _ POST ['m _ pw '];
$ Mydbname = $ _ POST ['m _ db'];
If (! @ Mysql_connect ("localhost", $ mydbuser, $ mydbpw )){
Echo "the mysql user name or password is incorrect. return to modify. <br> <a href = \ "# \" onClick = \ "window. history. back (); \ "> return </a> ";
Exit;
}
Mysql_query ("set names 'gbk '");
$ Dbsql = "create database if not exists". $ mydbname;
If (! @ Mysql_query ($ dbsql) {echo "check whether you have the permission to create a database"; exit ;}
Echo "database created {$ mydbname} succeeded >>< br> ";
Mysql_select_db ($ mydbname );
$ Char = '';
If (mysql_get_server_info ()> '4. 1') $ char = 'default CHARSET = gbk ';
$ SQL = "CREATE TABLE 'post '(
'P _ id' int (255) unsigned not null auto_increment,
'P _ name' varchar (20) not null,
'P _ email 'varchar (20) not null,
'P _ qq' varchar (20) not null,
'P _ homepage' varchar (100) not null,
'P _ image' varchar (8) not null,
'P _ title' varchar (160) not null,
'P _ content' mediumtext not null,
'P _ ip' varchar (15) not null,
'P _ date' datetime not null,
Primary key ('P _ id ')
) ENGINE = MyISAM {$ char };";
If (! @ Mysql_query ($ SQL) {echo "check whether the data table post exists. Delete it first."; exit ;}
Echo "succeeded in creating a data table post >>< br> ";
$ SQL = "insert into 'post' VALUES (1, 'I am not a fish', 'deng5765 @ 163.com ', '123', 'HTTP: // www.phpfans.net ', '01', 'Thank you for using the message board of a php enthusiast ','
<P> thank you very much for your support for the message board of php fans. </P>
<P> if you encounter any problems during use, go to </P>
<P> <A href = \ "http://www.phpfans.net/guestbook/\"> http://www.phpfans.net/guestbook/ </A> for help </P>
<P> or give your suggestion. You are also welcome to the php enthusiast site. </P>
<P> <A href = \ "http://www.phpfans.net/\"> http://www.phpfans.net </A> </P> ', '2017. 0.0.1 ', now ())";
If (@ mysql_query ($ SQL) {echo "data table initialized successfully <br> ";}
$ SQL = "CREATE TABLE 'reply '(
'R _ id' int (255) unsigned not null auto_increment,
'P _ id' int (255) not null,
'R _ content' varchar (255) not null,
'R _ rname' varchar (20) not null,
'R _ time' date not null,
Primary key ('R _ id '),
Unique key 'P _ id' ('P _ id ')
) ENGINE = MyISAM {$ char };";
If (! @ Mysql_query ($ SQL) {echo "check whether the data table reply exists. If so, delete it first."; exit ;}
Echo "data table reply created successfully >>< br> ";
$ Str = '<? Php '. "\ n ";
$ Str. = '$ mydbhost = \ 'localhost \ ''."; // Database Server \ n ";
$ Str. = '$ mydbuser = \ ''. $ mydbuser."'; // database username \ n ";
$ Str. = '$ mydbpw = \'. $ mydbpw. "'; // Database Password \ n ";
$ Str. = '$ mydbname = \ ''. $ mydbname."'; // Database Name \ n ";
$ Str. = '$ mydbcharset = \ 'gbk \ ''."; // database encoding. We do not recommend modifying. \ n ";
$ Str. = '$ admin = \ ''. $ _ POST ['m _ admin'].' \ '; // Administrator name'." \ n ";
$ Str. = '$ adminpw = \ ''. $ _ POST ['m _ adminpw']. '\'; // administrator password '." \ n ";
$ Str. = '$ eachpage = 5; // Number of message lines per page'. "\ n ";
$ Str. = '?> ';
$ Fp = fopen ('include/config. php', 'w ');
If (! $ Fp) {echo "this space does not support the file function. Please manually configure the content on config. php <br> ";}
Else {
Fwrite ($ fp, $ str );
Fclose ($ fp );
Echo "configuration document config. php updated successfully >>< br> <br> ";
Echo "installation is successful. For security reasons, please delete insall. php <br> ";
}
Echo'
<A href = "index. php"> go to the homepage of the message board </a> ';
Exit;
}
?>
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gbk"/>
<Title> php fan message board _ installation </title>
<Link type = "text/css" href = "guest.css" rel = "stylesheet">
</Head>
<Body>
<Center>
<? Php require_once('header.html ');?>
<Table id = "ptable" class = "tableboder" cellpadding = "0" cellspacing = "1">
<Form id = "form1" name = "form1" method = "post" action = "">
<Tr>
<Td colspan = "3" class = "header"> install a message board for php fans </td>
</Tr>
<Tr>
<Td> database server: </td>
<Td> <input name = "m_host" type = "text" id = "m_host" value = "localhost"> </td>
<Td> address of the database server, generally localhost </td>
</Tr>
<Tr>
<Td width = "220"> database username: </td>
<Td width = "266"> <input name = "m_root" type = "text" id = "m_root"/> </td>
<Td width = "280"> database account username </td>
</Tr>
<Tr>
<Td> Database Password: </td>
<Td> <input name = "m_pw" type = "password" id = "m_pw"/> </td>
<Td> password of the database account </td>
</Tr>
<Tr>
<Td> Database Name: </td>
<Td> <input name = "m_db" type = "text" id = "m_db"> </td>
<Td> automatic creation does not exist </td>
</Tr>
<Tr>
<Td> name of the message board administrator: </td>
<Td> <input name = "m_admin" type = "text" id = "m_admin"> </td>
<Td> </td>
</Tr>
<Tr>
<Td> message board administrator password: </td>
<Td> <input name = "m_adminpw" type = "text" id = "m_adminpw"> </td>
<Td> </td>
</Tr>
<Tr>
<Td colspan = "3"> <input type = "submit" name = "Submit" value = "Install"/>
After installation, you can modify the configuration in include/config. php. </td>
</Tr>
</Form>
</Table>
<? Php require_once('footer.html ');?>
</Center>
</Body>
</Html>