Write an HTML form, complaint.html, that
allows the user to generate complaint letters. The user will specify the first/last name of
the person to complain about, the person's gender, and how many sentences of complaints to
generate. Test your form by having it initially submit its data to
params.php. The following should be
the appearance of your form:
Once your form submits properly, write a PHP page
letter.php
on the server to process
this form data. On the server there is a file
sentence.txt
containing a bunch of
complaint sentences. Your PHP code should read this file, randomly pick sentences from it,
and turn these into a complaint letter. The file has one sentence per line. You will need
to personalize the letter by inserting the person's name and other information into it.
The following are the patterns you will need to replace:
_FNAME_
: person's first name_LNAME_
: person's last name_NAME_
: person's full name_HESHE_
: he (male) or she (female)_HIMHER_
: him (male) or her (female)_HISHER_
: his (male) or her (female)
You can use the str_replace
function
to help you replace the above patterns in the text. If you write the code correctly, you can
replace each placeholder with a single call. When you're finished with your page, it should
look like the following:
Your finished code might look like the following sample solution, written by TA Stefanie Hatcher: