View Single Post
Old 03-10-2009, 08:14 AM   #3 (permalink)
tony
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 295
Thanks: 8
tony is on a distinguished road
Default

Hi, just making sure I understand what you are asking.
The form is not submitted yet, right? It is first displayed and you want to load the information from the text file in the form's textboxes.

If that is the case
you would need to get the contents of the file line by line, then display the line content in the textbox.
I guess something like this:

PHP Code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
$fields
=file('input_file.txt');
foreach (
$fields as $field) {
    
$input=explode(" "$field);
    echo 
"\t<label for=\"$input[0]\">$input[0]:</label>"
    
echo " <input type=\"text\" name=\"$input[0]\" value=\"$input[1]\" /> <br />";
}
?>
<input type="submit" value="Submit" />
</form>
This is of course assuming the input is separated by a space and there is no spaces in the input values.

i don't know if that helped out.

Last edited by tony : 03-10-2009 at 08:17 AM. Reason: adding breaks between input fields and labels
tony is offline  
Reply With Quote