I have a text file that is changeable that I want to use to create a form with. Here is my text file, called 'test_read.txt" :
Now my PHP code, right now, is just supposed to print the info out for test purposes. My problem is that it only prints the two checkboxes with no values for them. My next question is can I put the <form></form> tags in this same file, or will I need to create another file for it? Here is my PHP code:
[PHP]<?php
$lines = file('test_read .txt');
foreach ($lines as $line) {
list($field, $value) = explode("=", $line);
$value = substr(trim($va lues), 0, 1);
echo get_html($field , $value);
}
function get_html($tag, $value) {
switch(trim($ta g)) {
case 'checkbox':
return "<input type=\"checkbox \" name=\"userbox\ " value=\"$value\ ">$value";
break;
case 'radio':
return "<input type=\"radio\" name=\"userbox\ " value=\"$value\ ">$value";
break;
// more cases below if needed.
}
}
?>[/PHP]
Code:
title = Test Form; checkbox = shoe; checkbox = hair; radio_button = 3; comment_box dropbox = 18-29; dropbox = 30-49; dropbox = 50-75; textbox = 50;
[PHP]<?php
$lines = file('test_read .txt');
foreach ($lines as $line) {
list($field, $value) = explode("=", $line);
$value = substr(trim($va lues), 0, 1);
echo get_html($field , $value);
}
function get_html($tag, $value) {
switch(trim($ta g)) {
case 'checkbox':
return "<input type=\"checkbox \" name=\"userbox\ " value=\"$value\ ">$value";
break;
case 'radio':
return "<input type=\"radio\" name=\"userbox\ " value=\"$value\ ">$value";
break;
// more cases below if needed.
}
}
?>[/PHP]
Comment