Posted by Andrι Medeiros on 11/13/99 11:21
What about...
<form action="saveConfig.php" method="post">
Database Host: <input type="text" name="config[database][host]"
value="<?=$config['database']['host']?>" /><br />
Database User: <input type="text" name="config[database][user]"
value="<?=$config['database']['user']?>" /><br />
<!-- some more fields here -->
</form>
And then...
<?php
$newConfigValues = $_POST['config'];
$fileCode = "<?php\n// AUTOMATICLLY CREATED CONFIG FILE. DO NOT EDIT!
\n";
foreach( $newConfigValues as $parentConfigKey => $parentConfigValue ) {
if( is_array( $parentConfigValue ) {
foreach( $parentConfigValue as $childConfigKey => $childConfigValue )
{
$fileCode .= "$config['$parentConfigKey']['$childConfigKey'] =
'$childConfigValue';\n";
}
}
else {
$fileCode .= "$config['$parentConfigKey'] = '$parentConfigValue'\n";
}
}
$fileCode .= "?>";
Navigation:
[Reply to this message]
|