PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Wed Jul 12, 2006 10:26 pm
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!?
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Thu Jul 13, 2006 12:13 am
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));
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Thu Jul 13, 2006 9:26 am
Still doesnt read the $config_data variable, any other ideas??
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Thu Jul 13, 2006 9:29 am
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.
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Thu Jul 13, 2006 9:37 am
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
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Thu Jul 13, 2006 9:46 am
i got it to work. thanks
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Thu Jul 13, 2006 11:21 am
if you don't mind would you share your soultion so that anyone expierencing a similar problem may recieve help
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Thu Jul 13, 2006 6:29 pm
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