Quick Search:
 
 PHP Code: How to write a config file Jump to:  
Category: >> PHP Code >> How to write a config file  

<< lastnext >>

Snippet Name: 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).

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: February 28th, 2009

<?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>


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org