我不能将$ _post值转换为chrome中的 ,但可以在IE中使用

问题描述:

I cannot $_post['value_to_be_posted'] value into a <form><input type="hidden" value="<? echo $_post['value_to_be_posted'] ?>"></form> in chrome but works in IE and ff.

Any ideas

Thanks Jean

我不能 $ _ post ['value_to_be_posted'] code>值到&lt; 表格&gt;&lt; input type =“hidden”value =“&lt;?echo $ _post ['value_to_be_posted']?&gt;”&gt;&lt; / form&gt; code>在Chrome中但在IE和ff中有效。 p>

任何想法 p>

谢谢 Jean p> div>

PHP won't care what browser is receiving the HTML it's generating. It'll spit out the same data for Chrome as it would for IE and FF. Most likely your POST value has one or more characters in it that are "breaking" the HTML of the page, and IE/FF are being a bit more forgiving than Chrome is. Try this:

<form action=... method="post">
<input type="hidden" name="fieldname" value="<?php htmlspecialchars($_POST['one']) ?>" />
</form>

Passing the insertable data through htmlspecialchars() will escape any HTML metacharacters, (the quote characters, the angle brackets, and ampersand: ' " < > &), and this will keep the inserted data from 'taking over' your form if any of those characters are present.

First: PHP is case sensitive, so it should be $_POST. Second: pay attention to the quotes - if your posted value has a " inside it, you'll have a problem.

This may be because of varying default method values for <form> elements. See here

Try using a specific <form method='POST'> and see whether it works better.