MySQL_Narb Posted October 17, 2009 Share Posted October 17, 2009 How do I make it so when a user submits information on the Install page, it'll right it into the correct file. I can do the forms and $_POST, but I need it so that it actually works. Current stuff in my config.php file: <?php $disabled = "0"; //Disable all posting and logging in? 1 for yes, 0 for no //Database information for your database $dbhost = ""; //Database hostname $dbuser = ""; //Database username $dbpassword = ""; //Database password $db = ""; //The database your selecting //The name of your site $sitetitle = "CommentBB"; //Your site link (MAKE SURE NO /'s are include!) Example: chataddict.netau.net (THATS ALL YOU NEED, NO HTTP OR trailing slash ) $link = "chataddict.netau.net"; //Site owner (So the site owner has a crown next to his/hers name when they comment/post) $owner = "Master"; //ACP password $apass = ""; //Mod CP password $mpass = ""; //Admin crowns $acrown = "crown_gold.gif"; //Moderator crowns $mcrown = "mod_silver.gif"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/ Share on other sites More sharing options...
MySQL_Narb Posted October 18, 2009 Author Share Posted October 18, 2009 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-938915 Share on other sites More sharing options...
MySQL_Narb Posted October 18, 2009 Author Share Posted October 18, 2009 ?............ ................................................. Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-938929 Share on other sites More sharing options...
Alex Posted October 18, 2009 Share Posted October 18, 2009 You didn't make it too clear what you need help with. Are you saying that the code you posted is the format of how the config.php file should be created with the information from the installation page inserted into it's designated area? If so it would probably be a good idea to create a file containing the template of that. It would look something like this: $dbhost = "{DB_HOST}"; //Database hostname $dbuser = "{DB_USER}"; //Database username $dbpassword = "{DB_PASSWORD}"; //Database password $db = "{DB}"; //The database your selecting ... Using file_get_contents() you can then get the contents of that file, then replace the replacements ({DB_HOST}, {DB_USER}, etc..) with the correct information. Example: $tpl = file_get_contents('config.txt'); // Template file as stated above $replace = Array('{DB_HOST}', '{DB_USER}', '{DB_PASSWORD}', '{DB}'); // Template replacements $values = Array($_POST['db-host'], $_POST['db-user'], $_POST['db-password'], $_POST['db']); // information from the installation page $tpl = str_replace($replace, $values, $tpl); // write $tpl to config.php Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-938950 Share on other sites More sharing options...
MySQL_Narb Posted October 18, 2009 Author Share Posted October 18, 2009 I don't understand, I have a config_test.php file, and I changed config.txt to config_test.php and I did a test, and it doesn't write the information into config_test.php... Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-938983 Share on other sites More sharing options...
MySQL_Narb Posted October 18, 2009 Author Share Posted October 18, 2009 Can anyone solve why? Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-939018 Share on other sites More sharing options...
mikesta707 Posted October 18, 2009 Share Posted October 18, 2009 can you post the actual code that you are using to write to the file? Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-939030 Share on other sites More sharing options...
MySQL_Narb Posted October 24, 2009 Author Share Posted October 24, 2009 Heres my code: <?php $tpl = file_get_contents('config_test.php'); // Template file as stated above $replace = Array('{DB_HOST}', '{DB_USER}', '{DB_PASSWORD}', '{DB}'); // Template replacements $values = Array($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['db']); // information from the installation page $tpl = str_replace($replace, $values, $tpl); // write $tpl to config.php ?> Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-943280 Share on other sites More sharing options...
trq Posted October 24, 2009 Share Posted October 24, 2009 Where do you write $tpl to your file? Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-943314 Share on other sites More sharing options...
MySQL_Narb Posted October 24, 2009 Author Share Posted October 24, 2009 Where do you write $tpl to your file? config_test.php: <?php $dbhost = "{DB_HOST}"; //Database hostname $dbuser = "{DB_USER}"; //Database username $dbpassword = "{DB_PASSWORD}"; //Database password $db = "{DB}"; //The database your selecting ?> Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-943318 Share on other sites More sharing options...
mikesta707 Posted October 24, 2009 Share Posted October 24, 2009 ??? post the code you use to write the data to the file.... you just posted the template file Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-943321 Share on other sites More sharing options...
MySQL_Narb Posted October 24, 2009 Author Share Posted October 24, 2009 ??? post the code you use to write the data to the file.... you just posted the template file Look above the damn post! I have another code posted! Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-943328 Share on other sites More sharing options...
Alex Posted October 24, 2009 Share Posted October 24, 2009 When I wrote that example I expected you to write the rest, the actual writing to config.php. Ex: file_put_contents('config.php', $tpl); Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-943332 Share on other sites More sharing options...
trq Posted October 24, 2009 Share Posted October 24, 2009 With that tone, I wouldn't have bothered. Quote Link to comment https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-943336 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.