Forum Moderators: coopster
I am trying to create a script that will take the MYSQl DB details that have been sent from a form and store it in a file for usage at a later stage.
Am I doing this correctly?
[php]
$File = "db-settings.php";
$Handle = fopen($File, 'w');
$Data = "$dbuser = $_POST['dbuser'];\n";
fwrite($Handle, $Data);
$Data = "$dbpass = $_POST['dbpass'];\n";
fwrite($Handle, $Data);
$Data = "$db = $_POST['db'];\n";
fwrite($Handle, $Data);
$Data = "$host = $_POST['host'];\n";
fwrite($Handle, $Data);
print "Data Written";
fclose($Handle);
[/php]
Any advice would be greatly appreciated :)
you're going to hate this answer
is it working? if it's working then you did it. Or are you concerned with some specific thing
if(!$Handle) {
it's funny, though I know all the docs say to do this, and it's right, the only time this matters is when you are reading only, the rest of the time it tries to create the file anyway, so if the dir doesn't exist then it's fine I guess, it's just a weird thing.
>> check anything else
make sure the file pointer was created, as you did, you should check all those POST vars.
hard to say how much you need to do since I am not totally sure what this could be used for