php configuration file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
azi.sathish
Forum Newbie
Posts: 2
Joined: Wed Jun 02, 2010 6:39 am

php configuration file

Post 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
User avatar
phdatabase
Forum Commoner
Posts: 83
Joined: Fri May 28, 2010 10:02 am
Location: Fort Myers, FL

Re: php configuration file

Post 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);
}
azi.sathish
Forum Newbie
Posts: 2
Joined: Wed Jun 02, 2010 6:39 am

Re: php configuration file

Post 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
Attachments
my requirement explained in this file
my requirement explained in this file
form.jpg (23.01 KiB) Viewed 568 times
pradeepgems
Forum Newbie
Posts: 4
Joined: Thu Mar 11, 2010 10:52 am

Re: php configuration file

Post by pradeepgems »

$username = "'" . $_POST["username"] . "'";
$usernameconst = "USERNAME''";
$string = "define($usernameconst,$username)";
file_put_content("c:\temp\config.php",$string);

try the above code.
Post Reply