php - problems with htmlspecialchars -


I am generating links with the following php code. The links appear in the browser, and the generated HTML code looks ok, although the links are not clickable, I have tested it in IE and FF, and tried to take no advantage of the firebug.

Code to generate my form

  $ uploadhtml = htmlspecialchars (json_encode ("
& Lt; / Form & gt; "), ENT_QUOTES);

Resulting HTML code:

  & quot; one onclick =" MacWindo (& amp; amp; Amp; quot; & lt; form action = & amp; # 39; up.php & amp; # 39; method = & amp; # 39; post & amp; # 39; r \ nactiepe = & amp; ; # 39; Multipart / Form-Data & amp; # 39; & gt; \ r \ n & lt; Label = & Amp; # 39; File & amp; # 39; File Name: & lt; \ / label & Gt; \ r \ n & lt; input type = & amp; # 39; file & amp; amp; # 39; name = & amp; # 39; file & amp; # 39; id = & amp; # 39 ; File & amp; # 39; \ & gt; \ r \ n 

\ r \ n & lt; input type = & amp; # 39; hidden & amp; # 39; Name = & amp; # 39; PK & # 39; value = & amp; # 39; 380118179930 & amp; nbsp; & gt; \ R \ n & lt; input type = & amp; # 39; hidden & amp; # 39; name = & amp; nbsp; user name & amp;; 39; value = & amp; # 39; generic & Amp; # 39; & gt; \ r \ n & lt; input type = & amp; # 39; submit & amp; # 39; name = & amp;; submit & amp; # 39; value = & Amp; # 39; Submit & amp; # 39; Onclick = \ & amp; Quot; Set Timeout (function () {updateByPk (& amp; # 39; Layer 2 & amp; # 39; 380118179930 & amp; # 39; Ed Hardy & amp; # 39; 39;, & amp; # 39; 1 & amp; # 39;);}), 1250); \ & Amp; Quot; \ / & Gt; \ R \ n & lt; \ / Form> & Amp; Quot; And ; # 39;); Return false, "href =" # "& gt; upload file

I think this is a JavaScript error, but I do not know whether it How can it be fixed?

Edit: ENT_QUOTES without HTML code:

  & lt; a href = "#" onclick = "MacWindows ('& amp; Quot; & lt; form action = 'up.php' method = 'post' \ r \ nctipse = 'multipart / form-data' & gt; \ r \ n & lt; label = 'file' & gt; File name: & lt; / label & gt; \ r \ n & lt; input type = 'file' name = 'file' id = 'file' \ / & gt; \ r \ N & lt; br / & Gt; \ r \ n & lt; in Type = 'hidden' name = 'PK' value = '380118185183' & gt; \ r \ n & lt; input type = 'hidden' name = 'username' value = 'Janmaybach' & gt; \ r \ N & lt; input type = 'submit' name = 'submit' value = 'submit' onclick = \ & amp; quot; set timeout (function () {updateByPk ('Layer2', '380118185183', 'Ed Hardy' , '1');}), 1250); \ & Amp; Quot; \ / & Gt; \ R \ n & lt; \ / Form> & Amp; Quot; '); Returned; "& Gt; Upload file & lt; / a & gt;  

It's still not clickable ..., is everything being correctly cited?

When I try without the special characters of html, the following HTML output is produced:

   type = 'submit' name = 'submit' Value = 'submit' onclick = "settimeout (function () =" "{=" "updatebypk (=" "layer2 =" "380118179930 =" "ad =" "hardy =" ", =" "1 =" " ); = ""} = ""), 1250); = "" & Gt; '); Return back; "& Amp; gt; Upload Files»  

As mentioned in the comment on this question, this is a terrible code, and you are suffering the consequences? The main problem is the number of code level: The server code that provides the JavaScript, which renders the HTML - and the difference is the difference between each Migrate to the level and interfere with each other.

To improve the situation, there is a separate PHP page Open your page and open your popup link - No Javascript is required If you do not really want to keep that separate page at all costs, then at least there is a Javascript function that appears in the header of the page (non-dynamic) And that link is only function with your function on that link with the parameter.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -