hotrod57 Posted November 6, 2007 Share Posted November 6, 2007 I have this php function that reads a text file for input to create a form. I am trying to get the form to print out the data on a separate page, but all I get is a blank page. Am I calling the page correctly, or is this even possible to do? <form action="phpform.php" method=POST> <?php $field=array(); $type=array(); $lines = file('test_read.txt'); foreach ($lines as $line) { list($mytype, $name, $option) = explode("=", $line); $name = htmlentities(trim($name)); if(isset($option)) $field[$name][]=htmlentities(trim($option)); else $field[$name]='nooptions'; $type[$name]=trim($mytype); } foreach ($field as $name => $options) { switch($type[$name]) { case 'label': print ("<p>$name<br>\n"); break; case 'checkbox': print ("<input type=\"checkbox\" name=\"$name\" id=\"$name\" value=\"true\"><label for=\"$name\">$name</label>\n"); break; case 'radio_button': print ("<p>$name<br>\n"); foreach($options as $value) print ("<input type=\"radio\" name=\"$name\" id=\"$name-$value\" value=\"$value\"><label for=\"$name-$value\">$value</label>\n"); break; case 'comment_box': print ("<p><label for=\"$name\">$name</label><br>\n"); print ("<p><textarea id=\"$name\" name=\"$name\" rows=\"4\" cols=\"50\"></textarea>\n"); break; case 'textbox': print ("<p><label for=\"$name\">$name: </label><input type=\"text\" id=\"$name\" name=\"$name\">\n"); break; case 'dropbox': print ("<p><label for=\"$name\">$name: </label><select name=\"$name\" id=\"$name\"><option></option>\n"); foreach($options as $value) print ("<option value=\"$value\">$value</option>\n"); print ("</select>"); break; } } print ("<p><input type=submit name=submit value=\"SUBMIT\"></form>\n"); print ("<input type=reset value=\"Reset\">\n"); ?> </form> Text File (just in case): title = Test Form label = Choose One of These checkbox = shoe checkbox = hair radio_button = Choose One = 3 radio_button = Choose One = 6 comment_box = Comments dropbox = Select = 18-29 dropbox = Select = 30-49 dropbox = Select = 50-75 textbox = Please type your name Quote Link to comment 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.