未定义的索引不对[重复]

I'm having problems making a online code editor, the current problem is that I made a text-area where the code from the file is gonna be. After I press the save button it needs to upload it, but I'm getting the well known error:

Notice: Undefined index: editor in /home/....../....../.../../ on line 30.

My code:

    ### FTP settings ###
$fileAdresRoot = $_SERVER['DOCUMENT_ROOT'];

        if(empty($_GET['name']))
        {
            header('Location: ftp-directory');
            exit();
        }
        else
        {
            $fileName   = trim($_GET['name']);
            $fileAdres  = $fileAdresRoot.'/'.$fileName.''; 
        }
            if(isset($_GET['doublename']))
            {
                $fileMaps   = trim($_GET['doublename']);
                $fileAdres  = $fileAdresRoot.'/'.$fileMaps.'/'.$fileName.'';
            }
        $fileContents   = fopen($fileAdres, 'rb', false);
        $fileContent    = stream_get_contents($fileContents);
### FTP settings ###

/* Saving the file */
if(isset($_POST['save']))
{
    **$textEditor   = trim($_POST['editor']);**
    $permisFile = chmod($fileAdres, 0777);


            **file_put_contents($fileAdres, $textEditor);**

    # Notify    
    $sGoed = 'U heeft succesvol het bestand opgeslagen!';
}
/* Code in between here.. */
<form method="post">
                    <p>U kunt terug naar de public_html map door <a href="ftp-directory">hierop</a> te klikken.</p>
                    <div class="pull-right"><strong>Huidige map: <?php echo $fileAdres; ?></strong></div>
                        <br />
                        <hr />
                        <br />
                    <pre id="editor"><textarea name="editor"><?php echo htmlentities($fileContent); ?></textarea></pre>
                        <hr />
                        <button type="submit" name="save" class="btn btn-primary">Wijziging opslaan</button>
                        <button type="submit" name="delete" class="btn btn-purple">Verwijderen</button>
                    </form>

Line 30:$textEditor = trim($_POST['editor']);

As requested: My JS:

    <script src="ace/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
    var editor = ace.edit("editor");
    editor.setTheme("ace/theme/chrome");
    editor.getSession().setMode("ace/mode/php");

    document.forms[0].onsubmit = function(){
        var theForm = document.forms[0];
        var newTextarea = document.createElement("textarea");  
        newTextarea.name = "editor";
        newTextarea.value = editor.getValue();
        theForm.appendChild(newOption); 
    }
</script>

As you can see, I've got no clue why the error is coming up. I've searched on Google but this isn't the normal type of problem with this error I think. Thank you in advance for helping! English isn't also my mother tongue, sorry for any grammar/spell mistakes.

</div>

Due to using the Ace-editor, the contents of <pre id="editor"></pre>, namely <textarea name="editor"></textarea>, are overwritten/modified, so your element is no longer in the DOM. You will need to recreate the editor element on form submit, something like -

<script>
    var editor = ace.edit("editor");

    ...
    your other js
    ...

    document.forms[0].onsubmit = function(){
        var theForm = document.forms[0];
        var newTextarea = document.createElement("textarea");  
        newTextarea.name = "editor";
        newTextarea.value = editor.getValue();
        theForm.appendChild(newOption); 
    }
</script>

or if you are using the jQuery library

<script>
    var editor = ace.edit("editor");

    ...
    your other js
    ...

    $(function(){
        $('form').on('submit',function(){
            $('<textarea>').attr({
                name: 'editor',
                value: editor.getValue()
            }).appendTo($(this)); 
        });
    });
</script>