X10nD
X10nD

Reputation: 22040

I cannot $_post value into a <form></form> in chrome but works in 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

Upvotes: 1

Views: 1661

Answers (3)

Marc B
Marc B

Reputation: 360702

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.

Upvotes: 1

Pekka
Pekka

Reputation: 449475

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.

Upvotes: 0

Maerlyn
Maerlyn

Reputation: 34107

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.

Upvotes: 0

Related Questions