Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago