TJS Posted June 18, 2008 Share Posted June 18, 2008 Hi all, I am new to PHP and am attempting to import a text file into a HTML input form. The text file has fields listed line by line e.g: test1 test 2 test3 I have worked out how to do this, however it is ignoring the spaces and only displaying the first part of the line in some instances, so in my example it would display "test1" and "test3" correctly however for the "test 2" line you would only see "test". Here is my code, I can confirm the variables work correctly when I display them individually, it may just be a syntax issue, I'm hoping. I am attempting to do this so the person adminstering the page doesn't have to update the entire list all the time, so in this case it will auto-populate it. The div2script.php file basically sends the data in the input fields to a file called div2side.txt. Upon opening the page I want the fields auto-populated with the details from the div2side.txt file. <?php // file() loads the contents of file.txt into an array, $lines // each line in the file becomes a seperate element of the array. $div2players = file('div2side.txt'); // now loop through the array to print the contents of the file foreach ($div2players as $div2player) { } echo ' <H3>Enter Division 2 Side:</H3> <FORM action=div2script.php method=post> <P>Team 1: <INPUT name=team1 value=';echo '' . htmlspecialchars($div2players[1]) . ''; echo '> Vs Team 2: <INPUT name=team2 value=';echo '' . htmlspecialchars($div2players[1]) . '';echo '><BR><HR> <P><INPUT type=submit value=Submit name=submit> <INPUT type=reset value=Reset name=reset> </FORM> <FORM action=displaydiv2side.php method=post> <INPUT TYPE="submit" VALUE=Display name=display </FORM> <HR> </P><BR> '; ?> I'm stuck, so any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/110728-importing-to-html-forms-input-boxes/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.