Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

posting hidden value

Tags:

forms

php

hidden

hey there, i have three pages: (1) bookingfacilities.php (2) booking_now.php (3) successfulbooking.php and they are link together.

i want to pass data from bookingfacilities.php to successfulbooking.php by using hidden field/value. however, my data doesn't get print out in successfulbooking.php.

here are my codes:

  • from 'booking_now.php': $date="$day-$month-$year";

  • from 'successfulbooking.php'; <input type="hidden" name="date" id="hiddenField" value="<?php print "$date" ?>"/>

i would greatly appreciate your help as my project is due tomorrow :(

like image 849
jocelync Avatar asked Jan 25 '11 15:01

jocelync


People also ask

How do you send a hidden value in a form?

The <input type="hidden"> defines a hidden input field. A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.

Is input type hidden safe?

Since they are not rendered visible, hidden inputs are sometimes erroneously perceived as safe. But similar to session cookies, hidden form inputs store the software's state information client-side, instead of server-side. This makes it vulnerable.


Video Answer


1 Answers

You should never assume register_global_variables is turned on. Even if it is, it's deprecated and you should never use it that way.

Refer directly to the $_POST or $_GET variables. Most likely your form is POSTing, so you'd want your code to look something along the lines of this:

<input type="hidden" name="date" id="hiddenField" value="<?php echo $_POST['date'] ?>" />

If this doesn't work for you right away, print out the $_POST or $_GET variable on the page that would have the hidden form field and determine exactly what you want and refer to it.

echo "<pre>";
print_r($_POST);
echo "</pre>";
like image 198
Michael Irigoyen Avatar answered Oct 17 '22 20:10

Michael Irigoyen