2014-02-10 110 views
-3

我想要做的是在用户输入数据库,用户名,密码和主机作为安装文件,作为php系统安装的第一步。用代码创建一个PHP文件

此外,我想创建一个网页,用户给他的模特页名和变量名($名称,$电子邮件),然后自动创建的PHP代码的文件像

class Admin extends MyBase 
{ 
    private $name,$email; 

    public function setName($v) 
    { 
     $this->name = $v; 
    } 
    public function setEmail($v) 
    { 
     $this->email = $v; 
    } 

    public function getName() 
    { 
     return $this->name; 
    } 
    public function getEmail() 
    { 
     return $this->email;  
    } 
     public function Insert() 
    { 
     $sql = "insert into 
     admin(name,email) 
     values('".$this->ms($this->name)."','".$this->ms($this->email)."')";  
     return $this->MyCommand($sql); 
    } 
} 

与编码格式。

+0

什么问题,你专门面对? – fiddler

+0

我可以创建一个文件,但不能用代码格式创建@fiddler – shanto

+0

代码格式?我没有看到代码中的任何文件创建行? –

回答

0

最后,我可以做一个例子

<?php 



if (isset($_POST["Submit"])) { 



$string = '<?php 

$dbhost = "'. $_POST["dbhost"]. '"; 

$dbuname = "'. $_POST["dbuname"]. '"; 

$dbpass = "'. $_POST["dbpass"]. '"; 

$dbname = "'. $_POST["dbname"]. '"; 

$prefix = "'. $_POST["prefix"]. '"; 

$user_prefix = "'. $_POST["user_prefix"]. '"; 

$dbtype = "'. $_POST["dbtype"]. '"; 

?>'; 



$fp = fopen("config.php", "w"); 

fwrite($fp, $string); 

fclose($fp); 



} 



?> 

<form action="" method="post" name="install" id="install"> 

    <p> 

    <input name="dbhost" type="text" id="dbhost" value=""> 

    DB Host 

</p> 

    <p> 

    <input name="dbuname" type="text" id="dbuname"> 

    DB Username 

</p> 

    <p> 

    <input name="dbpass" type="password" id="dbpass"> 

    DB Pass </p> 

    <p> 

    <input name="dbname" type="text" id="dbname"> 

    DB Name </p> 

    <p> 

    <input name="prefix" type="text" id="prefix"> 

    DB Prefix</p> 

    <p> 

    <input name="user_prefix" type="text" id="user_prefix"> 

    Userprefix</p> 

    <p> 

    <input name="dbtype" type="text" id="dbtype"> 

    DB Type </p> 

    <p> 

    <input type="submit" name="Submit" value="Install"> 

    </p> 

</form>