2014-02-10 181 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>