tags:

views:

106

answers:

3

Hello,

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

A: 

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.

Maerlyn
its done to $_POST
Jean
A: 

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.

Pekka
its method ='post' action=''
Jean
@Jean then why don't you say so in your question? This is why quoting the original HTML is a good thing.
Pekka
I have this form <form action="" method="post"> <input type="text" name="one" /> </form> and want the value of the above form when submitted to be the input of the hidden field in another form <form action="" method="post"> <input type="hidden" name="test" value="$_POST['one']"/> </form>
Jean
A: 

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.

Marc B