Snippet details
ID: 500
Viewed: 2437
Added: 2003-01-16
Version: php4.1+
Sorry no demo
This little script has come up a few times so I thought I would write a simle one for somebody to use. it will load a textbox so you can type some text in it and hit save. It will then save what ever you wrote in the textbox to a file on the server. The file will be saved in the same directory as this script is residing. It uses SuperGlobals and must have register Globals set to off to be functional. Very easy to modify to get more out of it. Good Luck
browsers: All
browsers: All
General Details
Snippet uploaded by: snippet
Email : webmaster@snippetlibrary.com
Snippet By: snippet
<!---Head--->
none
<!---Body--->
<?
if ($_POST['submit']){
// opens file for writing
$fileread = fopen("test.html", "w+")or die("Can't open file");
// check for special html characters and add slashes
$code = addslashes(htmlspecialchars($_POST['code']));
// right to file and insert all code
fwrite($fileread,$code);
// close file
fclose($fileread);
echo "File Saved";
} else {
//displays a textbox to enter some text to be saved.
echo "<div align="center"><form action="".$_SERVER['PHP_SELF']."" method="POST">";
echo "<b>Insert some words and hit save.</b><br>";
echo "<textarea type="text" name="code" rows="15" cols="75"></textarea><br>";
echo "<input type="submit" name="submit" value="Save"></form></div>";
}
// all done
?>
No Reviews to show
