config.php和Web安装

时间:2013-08-30 22:53:52

标签: php configuration installer config

我的网站安装有问题。我想进行网站安装,但我需要将其插入我的config.php文件中的表单。

这是config.php文件代码:

$conf = $TMPL = array(); 
$conf['host'] = '';
$conf['user'] = '';
$conf['pass'] = '';
$conf['name'] = '';
$conf['url'] = ''; 
$conf['mail'] = '';

我需要将示例“localhost”插入$conf['host'] = 'localhost';

的表单

1 个答案:

答案 0 :(得分:0)

<form action="" method="POST">
<input type="text" name="host">
<input type="text" name="user">
<input type="text" name="pass">
<input type="text" name="name">
<input type="text" name="url">
<input type="text" name="mail">
<input type="submit" name="submit">
</form>

<?php

if(isset($_POST['submit'])) {
 $host = $_POST['host'];
 $user = $_POST['user'];
 $pass = $_POST['pass'];
 $name = $_POST['name'];
 $url = $_POST['url'];
 $mail = $_POST['mail'];

 $configfile = "config.php";

 file_put_contents($configfile, "<?php 
\$conf = array();  \$conf['host'] = '". $host ."'; \$conf['user'] = '". $user ."'; \$conf['pass'] = '". $pass ."'; \$conf['name'] = '". $name ."'; \$conf['url'] = '". $url ."'; \$conf['mail'] = '". $mail ."';; ");
}