69 users online (0 members and 69 guests)  


  Results 1 to 2 of 2

Related

  1. #1
    psears's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2010
    Location
    San Mateo, Ca.
    Posts
    1

    Edit web page from HTML link

    I am trying to open an existing web page to edit and save from a web page button.

    I have initial web pages setup as informational and wish to update the pages without logging into server and using notepad.

    I want to click on a button to edit and another to post or save.

  2. #2
    firefly431's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2010
    Posts
    3

    Re: Edit web page from HTML link

    Hello! Here is a PHP (I really don't know how to do it with JS) code sample:
    PHP Code:
    <!-- PUT THIS IN BODY -->
    <?php
    if (isset($_POST['contents'])) {
        
    $fh=fopen($_POST['file_name'],'w');
        
    fwrite($_POST['contents']);
        
    fclose($fh);
        echo(
    "File Saved!");
    } else {
    $text file_get_contents(/*put filename here OR send this as a post from form (method=post) with filename text's name = file_name*/$_POST['file_name']/*or put 'FNAME' or $_GET['file_name'] with get or like: edit.php?file_name=FNAME*/);
    echo(
    "<form action='edit.php' method='post'>"); //form
    echo("<textarea name='contents'>"); //textarea
    echo($text);
    echo(
    "</textarea>"); //end textarea
    echo("<input type='hidden' value='".$_POST['file_name']."' name='file_name' />"); //filename
    echo("<input type='submit'>");
    echo(
    "</form>"); //end form
    }
    ?>