Google Chrome issue with POST variables in hidden fields

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
quiksilver02x
Forum Newbie
Posts: 2
Joined: Fri May 22, 2009 11:22 am

Google Chrome issue with POST variables in hidden fields

Post by quiksilver02x »

So I'm trying to do something very basic here: pass a variable via POST to another page, and echo that variable in a subsequent hidden field. I made a generic example:

page #1

Code: Select all

<body><form id="form1" name="form1" method="post" action="aa.php">
  <label>
  <input type="text" name="box1" id="box1" />
  </label>
  <label>
  <input type="submit" name="submit" id="submit" value="Submit" />
  </label>
</form>
</body>
page #2

Code: Select all

<body><form id="form1" name="form1" method="post" action="">
 Display passed variable: <?php echo $_POST["box1"]; ?><br />
<input name="take_box1" type="hidden" id="take_box1" value="<?php echo $_POST["box1"]; ?>" />
</form>
</body>
The variable will display when the echo statement is placed outside the hidden field, but will NOT display inside the hidden field.

I am only having this problem with Google Chrome. I'm about to lose my mind. Any ideas?
Last edited by Benjamin on Fri May 22, 2009 12:00 pm, edited 1 time in total.
Reason: Changed code type from text to html, php.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Google Chrome issue with POST variables in hidden fields

Post by Christopher »

quiksilver02x wrote:The variable will display when the echo statement is placed outside the hidden field, but will NOT display inside the hidden field.

I am only having this problem with Google Chrome. I'm about to lose my mind. Any ideas?
You need to do both if you want the value both displayed and passed. The field type is called "hidden" because it is not displayed, but is passed with the form.
(#10850)
quiksilver02x
Forum Newbie
Posts: 2
Joined: Fri May 22, 2009 11:22 am

Re: Google Chrome issue with POST variables in hidden fields

Post by quiksilver02x »

but why does it work with all browsers but chrome?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Google Chrome issue with POST variables in hidden fields

Post by Christopher »

If you view source, what exactly does the hidden field look like?

Also, why no <html></html> tags?
(#10850)
Post Reply