sambib Posted October 12, 2006 Share Posted October 12, 2006 Hi,I've got a long php/html form which I've broken up into pages for usability and I want to pass the collected vlaues from page to page in hidden fields, however it's not working.the data from the first page gets passed to the second like so:[color=blue][font=Verdana]<?phpif(isset($_POST['submit'])) { echo "<p>you entered: $dateOfBirth</p>";echo "<p>you entered: " . ($_POST['firstName']) . "</p>";[/font][/color]this is just for testing and at this stage it works (ie. the values appear on the page as i expect)[b]The values don't however get passed from here on....?[/b]:[color=blue]<form id="downloadForm" name="downloadForm" action="surveyform3.php" method="post"> <input type="hidden" name="firstName" value="<?php ($_POST['firstName']); ?>" /> <input type="hidden" name="dateOfBirth" value="<?php $dateOfBirth; ?>" /> <label for="submit" class="required"><span class="labelText">Continue to Page 3 of the Form:</span> <input id="submit" type="submit" name="submit" value="Next Page" /> </label></form>[/color]Here's the code for the following page and these echo statements don't show any values being passed:[color=blue]if(isset($_POST['submit'])) { echo "<p>you entered: " . ($_POST['dateOfBirth']) . "</p>";echo "<p>you entered: " . ($_POST['firstName']) . "</p>";[/color]the form continues......I've recently upgraded to php5 and I'm sure this was working a few weeks ago before the upgrade, so is there some syntax error or anything else I've missed....? Link to comment https://forums.phpfreaks.com/topic/23722-passing-values-in-hidden-fields-on-a-form/ Share on other sites More sharing options...
JasonLewis Posted October 12, 2006 Share Posted October 12, 2006 ok this error has been answered millions of times here. when your making the value="" your not echoing your php value...this:[code]<input type="hidden" name="firstName" value="<?php ($_POST['firstName']); ?>" />[/code]should be this:[code]<input type="hidden" name="firstName" value="<?php echo $_POST['firstName']; ?>" />[/code]see how I added the echo $_POST['firstName']. Because you just had it as the variable php wasn't doing anything with it. take more care next time and good luck. Link to comment https://forums.phpfreaks.com/topic/23722-passing-values-in-hidden-fields-on-a-form/#findComment-107748 Share on other sites More sharing options...
sambib Posted October 12, 2006 Author Share Posted October 12, 2006 cheers....when i was using php4 that code looked like this (and worked):<input type="hidden" name="firstName" value="<?= $_POST['firstName']; ?>" />but that doesn't work in php5 so i replace the [color=blue]<?=[/color] with [color=blue]<?php[/color], so the 'echo' wasn't required previously...so there you go, you learn something new everyday.... Link to comment https://forums.phpfreaks.com/topic/23722-passing-values-in-hidden-fields-on-a-form/#findComment-107773 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.