|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
configuration
you know on like phpbb where you fill out a form with the database information, etc and it sets that as all the veriables, well how does it do that? like how would the admin of the script put in his username and passwrod for the database in the config file and have it stay that way in the script wihtout him re entering it?
|
|
#2
|
|||
|
|||
|
RE: configuration
Quote:
It just saves them to a configuration file. You can download the phpBB source and check it out... |
|
#3
|
|||
|
|||
|
RE: configuration
i did but its really compressed, almost unreadable.. does it write it to a text file, or store it in a database or what?
|
|
#4
|
|||
|
|||
|
RE: configuration
The database settings would have to be stored in a text file, otherwise it wouldn't know how to connect to the database to retrieve the info
|
|
#5
|
|||
|
|||
|
RE: configuration
lol.. oops, ok so do i just write it to a text file?
|
|
#6
|
|||
|
|||
|
RE: configuration
yep..
|
|
#7
|
|||
|
|||
|
RE: configuration
index.php (form):
********************************** <form method="post" action="read.php"> <table><tr> <td>Mysql Host:</td><td><input type="text" name="dbhost" value="localhost"></input><br>your mysql host.</td></tr><tr> <td>Mysql UserName:</td><td><input type="text" name="dbuname" value="username"></input><br>your username to log into mysql.</td></tr><tr> <td>Mysql Password:</td><td><input type="text" name="dbpass" value="password"></input><br>your password to log into mysql.</td></tr><tr> <td>Mysql Database:</td><td><input type="text" name="database" value="ccshop"></input><br>The CCShop Mysql Database Name.</td></tr><tr> </tr></table> <input type="submit" name="submit" value="Next"></input> </form> *************************************** *************************************** read.php: *************************************** <? $infofile = "../config.php"; if (file_exists($infofile)) { print "The config file already exists"; } else { $info = fopen("$infofile", "a+"); fputs($info, "<?rn"); fputs($info, "$"); fputs($info, "dbhost"); fputs($info, "='$dbhost';rn"); fputs($info, "$"); fputs($info, "dbuname"); fputs($info, "='$dbuname';rn"); fputs($info, "$"); fputs($info, "dbpass"); fputs($info, "='$dbpass';rn"); fputs($info, "$"); fputs($info, "database"); fputs($info, "='$database';rn"); fputs($info, "="$"); fputs($info, "$"); fputs($info, "db = mysql_pconnect($"); fputs($info, "dbhost, $"); fputs($info, "dbuname, $"); fputs($info, "dbpass);rn"); fputs($info, "mysql_select_db($"); fputs($info, "database) or die ("Unable to select database");rn"); fputs($info, "?>rn"); fclose($info); } echo "<center>Your Config.php file has been created!"; ?> **************************************** **************************************** I put the $ seperated on each line because when the $variable is placed together you get your text instead of variable. ***************************************** like: fputs($info, "$"); fputs($info, "db = mysql_pconnect($"); fputs($info, "dbhost, $"); fputs($info, "dbuname, $"); fputs($info, "dbpass);rn"); makes: $db = mysql_pconnect($dbhost, $dbuname, $dbpass); ***************************************** if you put it in this script: fputs($info, "$"); fputs($info, "db = mysql_pconnect($dbhost, $dbuname, $dbpass);rn"); in place for database connect... it will make this: $db = mysql_pconnect(localhost, username, password); so you want to make sure you dont do that. unless you want the text placed there instead. like: fputs($info, "$"); fputs($info, "dbhost"); fputs($info, "='$dbhost';rn"); makes: $dbhost='localhost'; if localhost is what is typed in the textbox. this will create a config.php in the folder above the folder this script is in. like admin/install/ and puts the config.php in admin/ this is what i use, its to put info into a flat file database... your config.php will look like this: ****************************************** <? $login='admin'; $pass='pass'; $dbhost='localhost'; $dbuname='admin'; $dbpass='k4tm4nn'; $database='ccshop'; $db=mysql_pconnect($dbhost, $dbuname, $dbpass); mysql_select_db($database) or die ("Unable to select database"); ?> ************************** sorry this is so long, but it works.. its what i use for ccshop at www.spidermonster.com |
|
#8
|
|||
|
|||
|
RE: configuration
sorry, and the above is a config.php not a txt file, even though you can make it a text file. ths lets me save it as config.php
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > configuration |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|