I am using the following code snippet to generate a html form for use in a popup window:
$uploadhtml = "<form action='up.php' method='post'
enctype='multipart/form-data'>
<label for='file'>Filename:</label>
<input type='file' name='file' id='file'/>
<br />
<input type='hidden' name='pk' value='".$pk."'>
<input type='hidden' name='username' value='".$USERNAME."'>
<input type='submit' name='submit' value='Submit' onclick=\"setTimeout(function() { updateByPk('Layer2', '".$pk."', '".$brand."', '".$pg."'); } ),1250);\" />
</form>";
Everything is escaped/quoted as it should be.
I am using $uploadhtml like so:
echo "<p><a href='#' onclick=\"makewindows('" . $uploadhtml . "'); return false;\">Upload files</a>";
Why then is the escaped html the following?
<a href="#" onclick="makewindows('<form action='up.php' method='post'
enctype='multipart/form-data'>
<label for='file'>Filename:</label>
<input type='file' name='file' id='file'/>
<br />
<input type='hidden' name='pk' value='380118185183'>
<input type='hidden' name='username' value='janmaybach'>
<input type='submit' name='submit' value='Submit' onclick=" settimeout(function()="" {="" updatebypk(="" layer2="" 380118185183="" ,="" );="" }="" ),1250);="">
'); return false;">Upload files</a>
It is absolutely fine until it gets to the onclick parameter, and I see no reason it should generate it so obscurely.