我要做的是制作一个安装文件,用户输入数据库,用户名,密码和主机作为php系统安装的第一步。
此外,我想创建一个页面,用户可以在其中提供模型页面名称和变量名称($ name,$ email),然后自动创建一个包含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 :(得分: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>