E' un problema di configurazione del php.ini. Praticamente PHP ipotizza già che tu voglia codificare i caratteri speciali (aggiungendo la \), che altrimenti potrebbero causare problemi, ad esempio nelle query mysql. Questa stessa operazione si può eseguire con la funzione addslashes, e può venire invertita con la funzione stripslashes:
Codice PHP:
<?php
$username = "freedemo";
$password = "freedemo";
$viaForm = (md5(@$_POST["username"]) == md5($username) && md5(@$_POST["password"]) == md5($password));
$viaCookie = (md5(@$_COOKIE["username"]) == md5($username) && md5(@$_COOKIE["password"]) == md5($password));
$scadenza = time()+600;
if ($viaForm) {
setcookie("username", $_POST["username"], $scadenza);
setcookie("password", $_POST["password"], $scadenza);
}
if ($viaCookie) {
setcookie("username", $_COOKIE["username"], $scadenza);
setcookie("password", $_COOKIE["password"], $scadenza);
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</style>
<title>Scrivere su un file di testo</title>
</head>
<body>
<?php
if ($viaForm || $viaCookie) {
if (isset($_POST["article"])) {
$fp = fopen("testo.txt", "w+");
fwrite($fp, stripslashes($_POST["article"]));//Elimino gli slashes
fclose($fp);
}
$myText = file_get_contents("testo.txt");
?>
<form method="post">
<textarea name="article" cols="75" rows="10"><?php echo $myText; ?></textarea>
<input type="submit" value="Invia" />
</form>
<?php
} else {
?>
<form method="post" action="">
<label>username<input type="text" name="username" /></label>
<label>password<input type="password" name="password" /></label>
<input type="submit" name="Submit" value="Entra" />
</form>
<?php
}
?>
</body>
</html>
In alternativa, se hai accesso al php.ini, puoi impostare la direttiva magic_quotes (o un nome simile), su off.
Spero di esserti stato utile!