PHP-Script for a web-based Notepad?

I want to know how to make a web-based notepad with a PHP script... any Tutorial links you guys would have?

By web-based, I mean, something that would fopen() the file, and then write to it, such as:

$file = fopen('name', 'w');

But with more added to it, of course...
 
In its simplest form:

-----Index.html-----
<html>
<html>
<script type="text/javascript">
function getObj(){
if(window.XMLHttpRequest) return new XMLHttpRequest();
else if(window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else return null;
}

function init(){
var xhr = getObj();
if(xhr == null) return false;
var txt = document.getElementById("textInput").value;

xhr.onreadystatechange=function(){
if(xhr.readystate == 4) alert("Saved");
};
xhr.open("GET","save.php?txt=" + txt,true);
xhr.send(null);
}
</script>
</head>
<body>
<textarea cols="40" rows="2" id="textInput"></textarea>
<input type="button" onclick="init();" value="Save"/>
</body>
</html>

-----save.php-----
<?php
if(!$_GET['txt']) die("Error");
$file = fopen("filename.txt","w");
fwrite($file, $_GET['txt']);
fclose($file);
?>
 
Back
Top