use addslashes() before you save to file or sql statement.
DO NOT USE for the $query but for each field only.
use stripcslashes() after you read (ONLY) from file or database to display correctly. Use each field and not all the string.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<?php
session_start();
$textf1 = $_REQUEST['textf']; // slashes added by the POST command
$textf1 = stripslashes(htmlspecialchars($textf1)); // remove slashes
if($_REQUEST['Checkbox1'] == "on") { $_SESSION['texts'] = $textfX; }
$texts1 = $_SESSION['texts']; // slashes added automaticly
$texts1 = stripslashes(htmlspecialchars($texts1)); // remove slashes
function WC1($name,$val,$exp)
{
if ($exp == "") $exp = 0; else $exp = time() + $exp;
setcookie($name,$val,$exp,"/");
}
function RC1($CoKi)
{
if (isset($_COOKIE[$CoKi])) return $_COOKIE[$CoKi]; else return "";
}
WC1("TEST",addslashes(texts1),0); // add slashes
RC1("TEST",$textfX,0);
echo stripslashes(htmlspecialchars($textfX))."<br>"; // remove slashes
?>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>
<body>
<form method="post" action="s1.php">
<textarea name="textf" style="height: 83px; width: 264px"><? echo $textf1 ?></textarea>
<input name="Submit1" type="submit" value="submit">
<input name="Checkbox1" type="checkbox"> Click to set value</form>
<br>
<textarea name="TextArea2" style="height: 113px; width: 272px"><? echo $texts1 ?></textarea>
</body>
</html>