Exercise : Complaint Generator

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:
expected form output

Exercise : Complaint Generator

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:

Exercise : Complaint Generator

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:

expected form output

Exercise Solution

Your finished code might look like the following sample solution, written by TA Stefanie Hatcher: