amalafrida Posted December 16, 2011 Share Posted December 16, 2011 how do I populate the textbox values in form.html? Thanks in advance for any help you might offer. //formfill.php <?php $hours="akj"; //split string characters to array $hours_array = str_split($hours); //iterate through the characters in the array foreach($hours_array as $char) { echo($char."<br />"); //somehow populate text boxes in form.html } ?> //form.html <html> <body> <form> <table> <tr> <td><input type="text" name="hour[0]" value="" /></td> <td><input type="text" name="hour[1]" value="" /></td> <td><input type="text" name="hour[2]" value="" /></td> </tr> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/ Share on other sites More sharing options...
requinix Posted December 17, 2011 Share Posted December 17, 2011 value="" See that? That's where you put a value. Like value="" Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298708 Share on other sites More sharing options...
amalafrida Posted December 17, 2011 Author Share Posted December 17, 2011 Thanks for the response, requinix. However, I'm still not clear on this. Here's the code. When I call form_fill.php ... just a blank screen. <html> <body> <?php $hours="akj"; $hours_array = str_split($hours); foreach($hours_array as $value) { <form> <input name="lname" type="text" value="<?php echo htmlspecialchars( $value); ?>" /> </form> } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298907 Share on other sites More sharing options...
Pikachu2000 Posted December 17, 2011 Share Posted December 17, 2011 You have parse errors. You need to be developing with the following directives in your php.ini file: error_reporting = -1 display_errors = On Make those changes and restart Apache, then see what errors are generated. Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298908 Share on other sites More sharing options...
amalafrida Posted December 17, 2011 Author Share Posted December 17, 2011 my /etc/php5/cli/php.ini file shows: ; error_reporting : Default Value: E_ALL & ~E_NOTICE ; Development Value: E_ALL | E_STRICT ; Production Value: E_ALL & ~E_DEPRECATED error_reporting = -1 ; display_errors ; Default Value: On ; Development Value: On ; Production Value: Off display_errors = On restarted apache still just a blank screen when I call form_fill.php view source code ... nothing. Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298914 Share on other sites More sharing options...
Pikachu2000 Posted December 17, 2011 Share Posted December 17, 2011 See what the value are actually registered as by creating a new file with only the following code in it. Save it and navigate to it in your browser. <?php phpinfo(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298916 Share on other sites More sharing options...
amalafrida Posted December 18, 2011 Author Share Posted December 18, 2011 display_errors reports: Off ... for both local and master error_reporting reports: 22527 ... for both local and master Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298920 Share on other sites More sharing options...
amalafrida Posted December 18, 2011 Author Share Posted December 18, 2011 went to /etc/php5/apache2/ edited php.ini instead of /etc/php5/cli/php.ini set: display_errors = On error_reporting = -1 apache2 restart phpinfo() reports: display_errors = off error_reporting = 22527 Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298925 Share on other sites More sharing options...
Pikachu2000 Posted December 18, 2011 Share Posted December 18, 2011 Make sure the file that is shown as the loaded configuration file is the one you edited. If it is, you have a syntax error somewhere in the file. Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298930 Share on other sites More sharing options...
amalafrida Posted December 18, 2011 Author Share Posted December 18, 2011 phpinfo() reports: Loaded Configuration File /etc/php5/apache2/php.ini Scan this dir for additional .ini files /etc/php5/apache2/conf.d changed php.ini to: Default Value: On restarted apache reloaded form_fill.php received error message: Parse error: syntax error, unexpected '<' in formfill.php on line 9 but I don't see an error at line 9 ... code follows form_fill.php follows: <html> <body> <?php $hours="akj"; $hours_array = str_split($hours); foreach($hours_array as $value) { <form> //line 9 <input name="lname" type="text" value="<?php echo htmlspecialchars( $value); ?>" /> </form> } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298934 Share on other sites More sharing options...
manny Posted December 18, 2011 Share Posted December 18, 2011 This should fix your parse error. <html> <body> <?php $hours="akj"; $hours_array = str_split($hours); foreach($hours_array as $value) { ?> <form> <input name="lname" type="text" value="<?php echo htmlspecialchars( $value); ?>" /> </form> <?php } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298937 Share on other sites More sharing options...
amalafrida Posted December 18, 2011 Author Share Posted December 18, 2011 wow! snapped it right into line. I don't really get that final <?php ?> ... but it works and I'll note it. thanks to everyone for working me through this. pleasant to have gotten the immediate problem solved, but, perhaps more delightful, was to watch the diagnostic process, especially the phpinfo() bit. once again, many thanks to everyone. Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298942 Share on other sites More sharing options...
manny Posted December 18, 2011 Share Posted December 18, 2011 My pleasure. Feel free to contact me if you need any other help. Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1298944 Share on other sites More sharing options...
Pikachu2000 Posted December 18, 2011 Share Posted December 18, 2011 Just to be clear, I had you follow the steps to enable error reporting so you would at least have a fighting chance to find these types of errors without taking the time to post them to a message forum and wait for an answer. I could have simply corrected your code and reposted it, but you what would you have learned? Being able to debug code is an important part of coding. Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1299026 Share on other sites More sharing options...
manny Posted December 18, 2011 Share Posted December 18, 2011 true true, i agree. i would recommend doing both :-) fixing a simple code, will help the person see the differences. Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1299028 Share on other sites More sharing options...
amalafrida Posted December 18, 2011 Author Share Posted December 18, 2011 yes, yes. i think the approach was perfect. i'd much rather learn to handle/explore/diagnose than simply have the answer handed to me. knowing that first step ... looking at php.ini and phpinfo() were two priceless tips. of course, I'll be back for further info, but before I do, I'll certainly have a look at error reports ... and phpinfo() readout. once again, thanks for the assistance/solution/guidance. a. Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1299029 Share on other sites More sharing options...
manny Posted December 18, 2011 Share Posted December 18, 2011 my pleasure Quote Link to comment https://forums.phpfreaks.com/topic/253343-populate-text-box-values/#findComment-1299057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.