How To Write A Config File

Description: Easy way to collect user data and write it to a config file (for example, during an install).

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);
<form action="" method="post" name="install" id="install">
    <input name="dbhost" type="text" id="dbhost" value="">
    DB Host
    <input name="dbuname" type="text" id="dbuname">
    DB Username
    <input name="dbpass" type="password" id="dbpass">
  DB Pass </p>
    <input name="dbname" type="text" id="dbname">
  DB Name </p>
    <input name="prefix" type="text" id="prefix">
  DB Prefix</p>
    <input name="user_prefix" type="text" id="user_prefix">
    <input name="dbtype" type="text" id="dbtype">
  DB Type </p>
    <input type="submit" name="Submit" value="Install">

Enjoyed this post? Share it!


Leave a comment

Your email address will not be published.