john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

php edit htm

<html>
<head>
</head>
<body>
<?php
    $filecontents;
    $filename = "test.htm";


    $fpbackup = fopen($filename, 'r+'))  //r+ = read + write, start at beginning
    if (!$fp = fopen($filename, 'r+'))  //r+ = read + write, start at beginning
    {    echo "Cannot open file";
         exit;
    }

    if (is_writable($filename))
    {
        $filecontents = file_get_contents($filename);
        fclose($fp);
    }
    else {
        clearstatcache();
        echo "Cannot write to ".$filename." - Check permissions.";
    }


    echo "<b>" . $filename . "</b>" . " last modified: " . date("dMy H:s T", filemtime($filename));
?>


<form name="TextForm" method="post" action="
    <?php echo $_SERVER['php_SELF'];?>             ">

    <TEXTAREA name="txtcontents" ROWS="30" COLS="100" /><?php echo $filecontents ?></TEXTAREA>
    <br>
    <input type="submit" value="Submit" />
    <input type="submit" value="Backup" />

</form>

</body>
</html>

  • « php email example
  • php dirs and paths »

Published

Feb 6, 2010

Category

php

~85 words

Tags

  • edit 3
  • htm 1
  • php 82