Guest aceooo2 Posted March 4, 2007 Share Posted March 4, 2007 Hi, I am a beginner to PHP, I was wondring: Currently I can append and read the file I have appended. But I want to add an HTML form which inputs a textfield, and then actions it back to the PHP page. Also seondly I want to add instructions to test whether a variable passed from the form is NULL and if not outputs the value of the variable (But dont worry about this too much as I have not looked into it yet) The current code is:- <?php $File = "ws3.txt"; $Handle = fopen($File, 'a'); $Data = "William Green\n"; fwrite($Handle, $Data); $Data = "Dow Jones\n"; fwrite($Handle, $Data); print "Data Added<br><br><br>"; fclose($Handle); ?> <?php $myFile = "ws3.txt"; $handle = fopen($myFile, 'r'); while (!feof($handle)) { $data = fgets($handle, 512); echo $data; echo "<br>"; } fclose($handle); ?> Any ideas?, as when I search this PHP site or any others it only talks about uploading images or Link to comment https://forums.phpfreaks.com/topic/41110-php-inputting-and-echoing-a-whole-file-using-textfields/ Share on other sites More sharing options...
Guest aceooo2 Posted March 4, 2007 Share Posted March 4, 2007 Dont worry, I think I got it:- <?php $myFile = "ws3.txt"; $handle = fopen($myFile, 'r'); while (!feof($handle)) { $data = fgets($handle, 512); echo $data; echo "<br>\n"; } fclose($handle); ?> <html> <body bgcolor="#FFFFFF" text="#000000"> <form> Please Type in Your Name <br> <input type=text name=username><br> <input type=submit value="Submit Data"> </form> You Type: <?php echo($username); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/41110-php-inputting-and-echoing-a-whole-file-using-textfields/#findComment-199137 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.