Jump to content

Recommended Posts

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";

?>

Link to comment
https://forums.phpfreaks.com/topic/178066-solved-install-page/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-938950
Share on other sites

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

?>

Link to comment
https://forums.phpfreaks.com/topic/178066-solved-install-page/#findComment-943280
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.