im working next to school on a little 'CMS' (just for fun). It's pretty simple, just a site-selection, the textarea to edit and a save button. It actually works fine, I can see all my content and also can edit it an save it, but when I hit the save-button (in german: speichern) it all get's save at the index.php.
For example: I'm at site 'geschichte.php' with the content 'abc' and I edit the content to 'abcdef' it's get saved in index.php.
(As always, I'm having a hard time to explain
![Smile :)](./images/smilies/icon_e_smile.gif)
Here is my script:
[syntax=php]
<html>
<form method="post" action="">
<select name="seitenauswahl" size="1">
<option value="blabla/index.php">Index</option>
<option value="blabla/geschichte.php">Geschichte</option>
</select>
<input name="enter" type="submit" value="Auswählen"/>
</form>
<hr />
<!-- Quelltext-Editor (Script)-->
<?php
$Seite = $_POST["seitenauswahl"]; /* preeeeetty messy part :'D */
$edit = $Seite;
if (empty($edit)) {
$edit ="blabla/index.php";
$Seite = $edit; /* preeeeetty messy part :'D */
}
if(isset($_POST["dateiinhalt"]) && $dateiinhalt = $_POST["dateiinhalt"])
{
$handle = fopen($edit,"w");
fwrite($handle,$dateiinhalt);
fclose($handle);
echo '<p style="color:green;margin-bottom:20px;">'."\n";
echo 'Datei erfolgreich editiert!'."\n";
echo '</p>'."\n";
}
$fileinhalt = file_get_contents($edit);
?>
<!-- Quelltext-Editor (Eingabefeld)-->
<form action="" method="post">
Quelltext von der Datei im Pfad "<?php echo "$Seite"; ?>" bearbeiten:<br><br>
<!-- Currently editing file.... if you don't understand it :') -->
<textarea style="width:1500px;height:300px;" name="dateiinhalt">
<?php echo $fileinhalt; ?>
</textarea><br><br>
<input type="submit" name="submit" value="Speichern">
</form>
</html>
[/syntax]
I somehow need to write, when I hit save (=Speichern) that it should save the content on the current file (which I'm editing) and not at index.php.
Aww man it's soo easy and I don't get it :@
Anyways, I hope someone can help me!
![Smile :)](./images/smilies/icon_e_smile.gif)