A
Anonymous
Guest
Hello.
Apologies if I've come to the wrong forum.
Basically, I have created an installation file which accesses a database which, then creates tables. (hence posting here )
After the tables have been created. I would like to write the Database's Name, Username, Password and website url to a file on the server.
Then, when I type in my site's url. I would like the index.php file to load the file, and store the Database's Name, Username, Password and website url in variables.
This is where I'm getting stuck. I've written the code to save first.:-
// Get variables from form and set in php
$hostname = $_POST["txtDatabase_Host"];
$username = $_POST["txtDatabase_Username"];
$password = $_POST["txtDatabase_Password"];
$database = $_POST["txtDatabase_Name"];
$site_url = $_POST["txtSite_Url"];
// Write database information to a file.
include 'http://www.mywebsite.com/Core/sys/beardbf.txt';
$fp = fopen("http://www.mywebsite.com/Core/sys/beardbf.txt", 'w' ) or die("Coudn't open file");
echo "Try";
fwrite($fp, "Hello World.");
fputs($fp, "Hello World.");
fwrite($fp, $hostname);
fputs($fp, $hostname);
fwrite($fp, $database);
fputs($fp, $database);
fwrite($fp, $username);
fputs($fp, $username);
fwrite($fp, $password);
fputs($fp, $password);
fclose( $fp );
echo "Check file".
I would like to ask if the above code looks correct, or if not, how should I go about it please?
Thank You.
Apologies if I've come to the wrong forum.
Basically, I have created an installation file which accesses a database which, then creates tables. (hence posting here )
After the tables have been created. I would like to write the Database's Name, Username, Password and website url to a file on the server.
Then, when I type in my site's url. I would like the index.php file to load the file, and store the Database's Name, Username, Password and website url in variables.
This is where I'm getting stuck. I've written the code to save first.:-
// Get variables from form and set in php
$hostname = $_POST["txtDatabase_Host"];
$username = $_POST["txtDatabase_Username"];
$password = $_POST["txtDatabase_Password"];
$database = $_POST["txtDatabase_Name"];
$site_url = $_POST["txtSite_Url"];
// Write database information to a file.
include 'http://www.mywebsite.com/Core/sys/beardbf.txt';
$fp = fopen("http://www.mywebsite.com/Core/sys/beardbf.txt", 'w' ) or die("Coudn't open file");
echo "Try";
fwrite($fp, "Hello World.");
fputs($fp, "Hello World.");
fwrite($fp, $hostname);
fputs($fp, $hostname);
fwrite($fp, $database);
fputs($fp, $database);
fwrite($fp, $username);
fputs($fp, $username);
fwrite($fp, $password);
fputs($fp, $password);
fclose( $fp );
echo "Check file".
I would like to ask if the above code looks correct, or if not, how should I go about it please?
Thank You.