General Statistics
390 Tutorials
202 Total Votes
18 User(s) Online
770262 Views Total
3000 Registered Members
24534 Posts Total
Rooneyfeld is our newest member
About this Tutorial: Creating your Own Configuration File
Creating your Own Configuration File
Rated 4 / 1 Votes

Creating your Own Configuration File

Storing information has never became so fun. Set information in a php file with settings to use later without you ever editing the file by hand!


Date Added: November 20, 2005 [ 7738 Views - 1 Votes ] [ Rate ]

Author: Chaos King [ PHP Coding ] [ 3 Comment(s) ]

Creating your Own Configuration File

CODE
if ($_POST['Submit']) {

extract($_POST);

$file_to_write = 'config.php';
That is saying, if the Submit button has been hit, excecute the following stuff...



CODE
extract($_POST);
Means to extract the $_POST part of all variables, just making it $name, $username and so on. It makes it easier to handle.



CODE
$file_to_write = 'config.php';
That is the file in which you are saving to. You will have to chmod this file to 777 to allow the script to have the access to write to this file.


CODE
$content .="<?phpn";
$content .="$config['name'] = '$name';n";
$content .="$config['password'] = '$password';n";
$content .="$config['email'] = '$email';n";
$content .="$config['db_user'] = '$db_user';n";
$content .="$config['db_pass'] = '$db_pass';n";
$content .="$config['db_data'] = '$db_data';n";
$content .="$config['db_host'] = '$db_host';n";
$content .="?>";
That is what is going to be written. Using that, what ever that has will be written to the file. Using n means to make a break in english, to go to the next line. You use the same vairable for everything because its the same file, just adding on more to it to make it easier to see line by line. You use the .= to show that it is linked to each other. To make sure that nothing goes wrong.


Total Pages (4)
<<Prev 1 2 [3] 4 Next>>

Welcome User
Welcome Guest
( Login | Register )

Latest Tutorial Index - RSS Feed
Latest Resources - RSS Feed
Latest Tutorials - RSS Feed
Vote for Us
  • VixxIMG.com - Free Image Hosting, Free Myspace Image Hosting, Free Image Uploads
  • PageRank Plus - Google PageRank checking, with a twist.
Random Affilaites