Codice PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Text Editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
<!--
td{font-family:verdana,sans-serif; font-size:8pt;color:#333333};
body{font-family:verdana,sans-serif; font-size:11pt;color:#333333;font-weight:bold};
//-->
</style>
</head>
<body bgcolor="#eeeedd">
<center>
<font face="Tahoma">News Editor<br><br>
</font>
<table border="0" cellpadding="10" cellspacing="0" style="border:2px solid #ddddcc"><tr><td align="middle" bgcolor="#eeeedd">
<font face="Tahoma">Click on "Get" to display the current text file contents.<br>Enter text and click on "Submit" to update the text file.<br>Type <i>‹br›</i> to insert a linebreak.
</font>
<form action="edittext.php" method="post">
<table width="300" border="0">
<tr>
<td><font face="Tahoma"><textarea name="text_file" rows="20" cols="40"></textarea></font></td>
</tr>
</table>
<font face="Tahoma">
<input type="submit" value="Get" name="gettext"> <input type="submit" value="Submit" name="submit"> <input type="reset" value="Reset">
</font>
</form>
<font face="Tahoma">The text file currently contains the following text:<br><br>
</font></td></tr><tr><td align="left" width="500" bgcolor="#eeeedd"><hr color=#ddddcc>
<?php
if (isset($gettext)){
$myfile = fopen("news.txt","r");
$mydata = fread($myfile,filesize("news.txt"));
print $mydata;
}
else if (isset($submit)){
$myfile = fopen("news.txt","w+");
$entry = ereg_replace("\n","
",$entry);
$entry = stripslashes($entry);
$mydata = "&news= $text_file &
\n\n";
fwrite($myfile,$mydata);
fclose($myfile);
//QUI DEVI EDITARE
mail("INDIRIZZO@NOTIFICA.IT", "OGGETTO NOTIFICA", "E' stato modificato il file news.txt");
$myfile = fopen("news.txt","r");
$mydata = fread($myfile,filesize("news.txt"));
print $mydata;
}
?>
<hr color=#ddddcc>
</td></tr></table>
</center>
</body>
</html>
Prova così