For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > March 2006 > Text file (rw) question...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Text file (rw) question...
Rob W.

2006-03-14, 9:55 pm

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

index.php

<?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 "<form method=\"POST\" action=\"update.php\">";
if ($variable == "MaxUser") {
echo "Max Users: <input type=\"text\" value=\"$data\" name=\"MaxUser\" size=\"3\"><br />";
}
if ($variable == "Password") {
echo "Password: <input type=\"text\" value=\"$data\" name=\"Password\" size=\"15\"><br />";
}
// echo "$variable $data<br />";
}
fclose($f);

echo "<p /><input type=\"SUBMIT\" value=\"Submit\" /></form>";

?>

update.php

<?

$newconfig = "";

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

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


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


exit();

?>

Thankyou to everyone who helped. Special thanks to Chris.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com