Question
File: modify1.php Purpose:Chapter 6 Exercise REQUIREMENT: Write a Web-based application consisting of a Web form (modify1.html) and a PHP program (modify1.php). modify1.html includes a form
File: modify1.php Purpose:Chapter 6 Exercise
REQUIREMENT: Write a Web-based application consisting of a Web form (modify1.html) and a PHP program (modify1.php).
modify1.html includes a form that prompts the user for a country and the capital city of that country. When this is submitted, modify1.php receives the two inputs and writes this to a file named capitals.txt Run the program a few times, each time entering a different country and capital. After each each submission, open capitals.txt to see that the file has been changed. Note the previous content of the file is lost each time new input is submitted. That's because the file is opened for write operations.
Now modify modify1.php so that the file is opened for append operations instead of write operations. Run the program a few times, each time entering a different country and capital. After each each submission, open capitals.txt to see that the file has been changed. Note that now each new submission is added to the existing file.
-->
Modify1
$capitalFile = fopen("capitals.txt","w"); // open the file for write operations
fputs($capitalFile, "$country:$capitalCity ");// write the input to the file fclose($capitalFile);
print("
The following information has been stored in the file capitals.txt:
"); print("$country:$capitalCity
"); ?>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started