maybe this can help, not sure...
<?
if($code != '')
{
echo "<br>this is code before stripslashes ".$code;
}
$code = stripslashes($code);
if($code != '')
{
echo "<br>this is code after stripslashes ".$code;
echo "<br>this is where you should be doing your fwrite!!!";
}
?>
<form action="try_exam.php" method="post">
<input type="text" size="50" name="code">
<input type="submit" value="submit">
</form>
/////////this is the output below/////////
this is code before stripslashes fopen(\"whatever.php\");
this is code after stripslashes fopen("whatever.php");
this is where you should be doing your fwrite!!!
//hopes this helps