Page 1 of 1

php configuration file

Posted: Wed Jun 02, 2010 6:50 am
by azi.sathish
Hi all,

I want to have a configuration file for my webapplication where it will have some fields like Database name, DB username, DB pass and when submitting this it should be saved in a php file (configuration file) i tried trying but didn't get the code., if anyone knows plz let me know. Thanks

S

Re: php configuration file

Posted: Wed Jun 02, 2010 9:15 am
by phdatabase
Create an config.ini file (a text file)

Code: Select all

TIME_LIMIT=0
TITLE=modbot
SERIAL_NO=
DATA_PATH=C:/htdocs/modbot/data/
LOG_PATH=C:/htdocs/modbot/logs/
MOD_PATH=C:/htdocs/modbot/Modules/
USE_DB=false
BROWSER_LIST=C:/htdocs/modbot/data/browsers.txt
REFERER_LIST=C:/htdocs/modbot/data/referer.txt
TARGET_LIST=C:/htdocs/modbot/data/targets.txt
Then on each page read and process the config.ini file.

Code: Select all

$iniArray = parse_ini_file('config.ini');
foreach( $iniArray as $key=>$value) {
	define( $key, $value);
}

Re: php configuration file

Posted: Thu Jun 03, 2010 2:22 am
by azi.sathish
Dear my Friend

I am new to php, sorry i couldn't understand about that ini file...

please find the attached image file, you will get an idea about my requirement.

Thanks and waiting for your reply

sathish

Re: php configuration file

Posted: Thu Jun 03, 2010 8:33 am
by pradeepgems
$username = "'" . $_POST["username"] . "'";
$usernameconst = "USERNAME''";
$string = "define($usernameconst,$username)";
file_put_content("c:\temp\config.php",$string);

try the above code.