Page 1 of 1
[HELP] fwrite
Posted: Wed Jul 12, 2006 10:26 pm
by bla5e
Code: Select all
<?php
$config_data = '<?php'."\n\n";
$config_data .= "\n//auto-generated config file for $sitename \n// Do not change anything in this file!\n\n";
$config_data .= '$sitename = \'' . $_POST['sitename'] . '\';' . "\n\n";
$config_data .= '$siteterms = \'' . $_POST['siteterms'] . '\';' . "\n\n";
$config_data .= '$siteauthor = \'' . $_POST['siteauthor'] . '\';' . "\n\n";
$config_data .= '$adminusn = \'' . $_POST['adminusn'] . '\';' . "\n\n";
$config_data .= '$adminpw = \'' . $_POST['adminpw'] . '\';' . "\n\n";
$config_data .= '$host = \'' . $_POST['host'] . '\';' . "\n\n";
$config_data .= '$db = \'' . $_POST['db'] . '\';' . "\n\n";
$config_data .= '$username = \'' . $_POST['username'] . '\';' . "\n\n";
$config_data .= '$password = \'' . $_POST['password'] . '\';' . "\n\n";
$config_data .= '?' . '>';
$data = fopen("config.php", "w");
fwrite($data, stripslashes($HTTP_POST_VARS['config_data']));
fclose($data);
echo "File created";
break;
?>
(There is a form before this page)
It wont write the config.php file, but it reads the $_POST variables..
why wont it work!?
Posted: Thu Jul 13, 2006 12:13 am
by Burrito
you're trying to access config_data from an array key in HTTP_POST_VARS.
try changing it to this:
Code: Select all
fwrite($data, stripslashes($config_data));
Posted: Thu Jul 13, 2006 9:26 am
by bla5e
Still doesnt read the $config_data variable, any other ideas??
Posted: Thu Jul 13, 2006 9:29 am
by Burrito
do this:
1) try echoing out the $config_data var to make sure you're dealing with the correct stuff
2) make sure you have permissions to write a file in the folder you're working on.
Posted: Thu Jul 13, 2006 9:37 am
by bla5e
Burrito wrote:do this:
1) try echoing out the $config_data var to make sure you're dealing with the correct stuff
2) make sure you have permissions to write a file in the folder you're working on.
1) i did any nothing is expressed, but if i echo the $_POST data it does..
2) Ive got CHMOD 777 on both the folder and the config.php file
Posted: Thu Jul 13, 2006 9:46 am
by bla5e
i got it to work. thanks
Posted: Thu Jul 13, 2006 11:21 am
by dull1554
if you don't mind would you share your soultion so that anyone expierencing a similar problem may recieve help
Posted: Thu Jul 13, 2006 6:29 pm
by bla5e
dull1554 wrote:if you don't mind would you share your soultion so that anyone expierencing a similar problem may recieve help
didnt chmod the folder
