Text file (rw) question...

Text file (rw) question...

am 15.03.2006 03:11:47 von Rob

------=_NextPart_000_040D_01C647A3.85BF35A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

It's all fixed and works. If anybody is wondering how this turned out, =
here's the begining of the results.

index.php


if (!($f=3Dfopen("sc_serv.conf","r")))
exit("Unable to open file.");
while (!feof($f))
{
$x=3Dfgets($f, 100);
list($variable, $data) =3D explode("=3D", $x);
echo "

";
if ($variable == "MaxUser") {
echo "Max Users: name=3D\"MaxUser\" size=3D\"3\">
";
}
if ($variable == "Password") {
echo "Password: name=3D\"Password\" size=3D\"15\">
";
}
// echo "$variable $data
";
}
fclose($f);

echo "

";

?>

update.php


$newconfig =3D "";

$maxuser=3D$_POST['maxuser'];
$password=3D$_POST['password'];

foreach($_POST as $area =3D> $value) {
$newconfig .=3D $area . "=3D" . $value . "\n";
}


$fp =3D fopen('sc_serv.conf', 'w');
fputs($fp, $newconfig);
fclose($fp);


exit();

?>

Thankyou to everyone who helped. Special thanks to Chris.
------=_NextPart_000_040D_01C647A3.85BF35A0--

Re: Text file (rw) question...

am 15.03.2006 04:02:04 von Chris

Rob W. wrote:
> It's all fixed and works. If anybody is wondering how this turned out, here's the begining of the results.
>
> index.php
>
> >
> if (!($f=fopen("sc_serv.conf","r")))
> exit("Unable to open file.");
> while (!feof($f))
> {
> $x=fgets($f, 100);
> list($variable, $data) = explode("=", $x);
> echo "

";
> if ($variable == "MaxUser") {
> echo "Max Users:
";
> }
> if ($variable == "Password") {
> echo "Password:
";
> }
> // echo "$variable $data
";
> }
> fclose($f);
>
> echo "

";
>
> ?>
>
> update.php
>
> >
> $newconfig = "";
>
> $maxuser=$_POST['maxuser'];
> $password=$_POST['password'];


You're not using these variables anywhere so it'd be best to remove them
(might be confusing later on if you need to come back to it).

or you can leave them there and do:

$newconfig = '';
$newconfig .= "MaxUser=" . $maxuser . "\n";
$newconfig .= "Password=" . $password . "\n";

instead of the foreach($_POST... loop.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Text file (rw) question...

am 15.03.2006 04:05:34 von Rob

Ah yes, that's true. I didnt realize that. Thanks for pointing that out.


----- Original Message -----
From: "Chris"
To: "Rob W."
Cc:
Sent: Tuesday, March 14, 2006 9:02 PM
Subject: Re: [PHP-DB] Text file (rw) question...


> Rob W. wrote:
>> It's all fixed and works. If anybody is wondering how this turned out,
>> here's the begining of the results.
>>
>> index.php
>>
>> >>
>> if (!($f=fopen("sc_serv.conf","r")))
>> exit("Unable to open file.");
>> while (!feof($f))
>> {
>> $x=fgets($f, 100);
>> list($variable, $data) = explode("=", $x);
>> echo "

";
>> if ($variable == "MaxUser") {
>> echo "Max Users: >> name=\"MaxUser\" size=\"3\">
";
>> }
>> if ($variable == "Password") {
>> echo "Password: >> name=\"Password\" size=\"15\">
";
>> }
>> // echo "$variable $data
";
>> }
>> fclose($f);
>>
>> echo "

";
>>
>> ?>
>>
>> update.php
>>
>> >>
>> $newconfig = "";
>>
>> $maxuser=$_POST['maxuser'];
>> $password=$_POST['password'];
>
>
> You're not using these variables anywhere so it'd be best to remove them
> (might be confusing later on if you need to come back to it).
>
> or you can leave them there and do:
>
> $newconfig = '';
> $newconfig .= "MaxUser=" . $maxuser . "\n";
> $newconfig .= "Password=" . $password . "\n";
>
> instead of the foreach($_POST... loop.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php