Question: Create a document with a form that registers all organic farmers in the area and the non-GMO crop they grow. Your program will create a
Create a document with a form that registers all organic farmers in the area and the non-GMO crop they grow. Your program will create a single text le that saves information for each farmer on a separate line. The name of the data file is data.txt. The file should be created in the same directory as your running program, without hard-coding the file path to ensure portability. (This means that when I am running your file, I will copy it to my working directory, and after I run your program entering information, the file will be created in the same folder as the program).
In the data file include the farmers name, age, crop type, and pounds grown, separated by commas. Age and Pounds should only accept numbers, crop should only accept corn, soybeans, and tomatoes. The first line of the output will be the headers.
Name, Age, Crop, Pounds John Smith, 23, corn, 200 Sally Brown, 34, soybeans, 550
I am not familiar with data text files while using php i am confuse on how to start the document off and what exactly to code here is all i figured out
MY CODE------
*// Writting the file*//
$handle= fopen($my_file, "w") $txt = John Smith ; $Age = 23 ; $crop = corn; ; $pounds = 200 ; fwrite($my_file, $txt);
$txt = Sally Brown ; $Age = 34 ; $crop = soybeans ; $pounds = 550 ; fwrite($my_file, $txt); fclose($my_file); ?>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
