fwrite function

Discussion in 'PHP' started by ItamarP, Dec 13, 2009.

  1. #1
    hey there ,i've got a question about the fwrite function

    there's an html code , i want to write

    <html>
    <head>
    <form action="edit_content.php" method="post">
    <title><h2>delete content</h2></title>
    <h1>choose content to delete</h1>
    <select>

    I WANT TO FWRITE TO WRITE HERE

    <input type="submit" value="submit" name="submit">

    </select>
    </form>
    </head>
    </html>


    is it possible? how ?
     
    ItamarP, Dec 13, 2009 IP
  2. zoneweb

    zoneweb Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here's how you do it:

    <html>
    <head>
    <form action="edit_content.php" method="post">
    <title><h2>delete content</h2></title>
    <h1>choose content to delete</h1>
    <select>

    <?php
    // *** insert your fwrite function here ***
    ?>

    <input type="submit" value="submit" name="submit">

    </select>
    </form>
    </head>
    </html>
     
    zoneweb, Dec 13, 2009 IP
  3. ItamarP

    ItamarP Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    you gotta be kidding

    there's one more .php file instead of this html file
    in the php file there's a fwrite function whice writes into the html file
    i want it to write into a specific place in the html file
     
    ItamarP, Dec 13, 2009 IP
  4. kingsoflegend

    kingsoflegend Well-Known Member

    Messages:
    202
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Open the html file with fread, parse it, insert the code you want then use fwrite to overwrite the original file with the new code.
     
    kingsoflegend, Dec 13, 2009 IP
  5. Wogan

    Wogan Peon

    Messages:
    81
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    0
    #5
    Ok, so you've got a function that writes data into a .html file, right?

    Let's say you've got:

    $string = "This data goes in the HTML file at a specific point.";
    PHP:
    And you've got:

    $html = "<html> ... Your HTML page ... </html>";
    $handle = fopen("my.html", "w+");
    fwrite($handle, $html);
    fclose($handle);
    PHP:
    What you want to do is this:

    <html>
    <head>
    <form action="edit_content.php" method="post">
    <title><h2>delete content</h2></title>
    <h1>choose content to delete</h1>
    <select>
    
    <!-- I WANT TO FWRITE TO WRITE HERE -->
    {MY_FWRITE}
    
    <input type="submit" value="submit" name="submit">
    
    </select>
    </form>
    </head>
    </html>
    HTML:
    $html = "<html> ... Your HTML page ... </html>";
    
    $html = str_replace("{MY_FWRITE}", $string, $html);
    
    $handle = fopen("my.html", "w+");
    fwrite($handle, $html);
    fclose($handle);
    
    PHP:
     
    Wogan, Dec 13, 2009 IP