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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!