Hvis der er nogen der skulle være interesseret i mit script er det her:
<?php
if($_POST['formSubmit'] == "Submit")
{
$varTitel = $_POST['formTitel'];
$varHead = $_POST['formHead'];
$varText = $_POST['formText'];
while (file_exists($file)) {
echo("Titlen du prøver at oprette findes allerede");
}
$f = fopen( "../works/files/" . $varTitel, "w");
fwrite($f, "
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>" . $varHead . "</title>
<link rel='stylesheet' type='text/css' href='../style.css'/>
</head><html><body><center><h1>" . $varHead . "</h1>" . $varText . "\n" . "</center></body></html>");
fclose($f);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Works 1</title>
</head>
<body>
<div id="admin_form">
<form action="myform1.php" method="post">
<p>
Titel/menu:<br>
<input type="text" name="formTitel" maxlength="50" class="tekst_head" value="<?=$varHead;?>" />
</p>
<p>
Overskrift/menu punkt:<br>
<input type="text" name="formHead" maxlength="50" class="tekst_head" value="<?=$varHead;?>" />
</p>
<p>
Tekst:<br>
<input type="text" name="formText" class="tekst" value="<?=$varText;?>" />
</p>
<input type="submit" name="formSubmit" value="Submit" />
<input type="button" value="Clear" onClick="history.go(0)"><br><br>
</form>
</div>
<div id="dynamic_menu">
<?php
// Variabel der definere folder
$path = "../works/files/";
// opendir funktion (folder) = $dir_handle variabel. Hvis folderen ikke findes skriv "Unab...
$dir_handle = @opendir($path) or die("Unable to open $path");
echo "<span style='font-family: Verdana, Helvetica, sans-serif; font-size:10px; padding-bottom:10px;'>
Her er dine sider:</span><br/><br/>";
// while løkke der tjekker filer fra $dir_handel
while ($file = readdir($dir_handle))
{
if($file!="." && $file!="..")
echo "
<ul>
<li>
<a href='files/$file' target='_blank'>$file</a> <br/>
</li>
</ul>
";
}
// lukker
closedir($dir_handle);
?>
</div>
</body>
</html>
Lidt roddet sat sammen, men det virker.