Is my method the best way to accomplish this? If not, please elaborate. If so, how can I refresh the page?
Code: Select all
<?php
$filename = "../style/style.css";
$fh = fopen($filename, 'r') or die("Can't open file");
$fc = fread($fh, filesize($filename));
fclose($fh);
echo "<form method='post' action='admin.php?option=mod_styleconfig' >
<textarea rows='20' cols='90' name='css'>".$fc."</textarea><br />
<input type='submit' />
</form>";
if(isset($_POST['css'])){
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file $filename";
exit;
}
if (fwrite($handle, $_POST['css']) === FALSE) {
echo "$filename is not writable";
exit;
}
fclose($handle);
} else {
echo "$filename is not writable";
}
}
?>