2013-08-30 24 views
0

我有安装网站的问题。我想做网站安装,但我需要一个将它插入到我的config.php文件中的表单。config.php和网页安装

这里的config.php文件代码:

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

我需要的形式,将插入例如“本地主机”到$conf['host'] = 'localhost';

回答

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 ."';; "); 
} 
+0

我试过FWRITE,但仍显示在行错误23个file_put_contents。 –

+0

\ $ conf ['host'] =“'。$ host。'”; \ $ conf ['user'] =“'。$ user。'”; \ $ conf ['pass'] =“'。$ pass。'”; \ $ conf ['name'] =“'。$ name。'”; \ $ conf ['url'] =“'。$ url。'”; \ $ conf ['mail'] =“'。$ mail。'”; –

+0

更新了答案,代码现在可以正常工作 – Exwolf