(10 points) Create a HTML form address.html to collect people’s names and addres
ID: 665347 • Letter: #
Question
(10 points) Create a HTML form address.html to collect people’s names and addresses. Include 5 textboxes:
1- name
2- address line 1
3- address line 2
4- city
5- zip code
Also include a submit button, a reset button, and a drop down menu with all the states in the US.
(40 points) Create address.cgi to collect and store the address data from address.html into a text file called address.txt . If the user leaves any field blank (except for address line 2), your address.cgi should display an error message and not add any data to the file. Otherwise, it should add a new row. The address.txt file should look like this:
Name, Address1, Address2, City, State, Zip
J Duncan, 901 E 10th street,,Bloomington,Indiana,47408
Jane Smith, 901 E 10th street, Box 27, Bloomington, IN, 47408
John Cooper, 105 S. Woodlawn Ave, Apt 2, Bloomington, IN 4740
…
Remember to use the “a” (append) mode to write to the text file. You should not erase previously entered data. Create the text file with the header information only first. Do not add data to the file when an error occurs.
(10 point BONUS) Modify address.cgi so that it prints out the information currently in address.txt as a nicely formatted table. Include the information just submitted if it was valid.
This should be done in python
Explanation / Answer
address.html
<form id="contact_form" action="test.py" method="POST" enctype="multipart/form-data">
<div class="row">
<label for="name">Your name:</label><br />
<input id="name" class="input" name="name" type="text" value="" size="30" /><br />
</div>
<div class="row">
<label for="address1">Address1:</label><br />
<input id="addressone" class="input" name="addressone" type="text" value="" size="30" /><br />
</div>
<div class="row">
<label for="address2">Address2:</label><br />
<input id="addresstwo" class="input" name="addresstwo" type="text" value="" size="30" /><br />
</div>
<div class="row">
<label for="city">City:</label><br />
<input id="city" class="input" name="city" type="text" value="" size="30" /><br />
</div>
<div class="row">
<label for="zip">Zip Code:</label><br />
<input id="zip" class="input" name="zip" type="text" value="" size="30" /><br />
</div>
<input id="submit_button" type="submit" value="Send Details" />
</form>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.