Submission 03
Accessing Quotes from a MongoDB Database and Implementing a Feedback Form
In this submission you will continue your website enhancement by making the following additions/changes:
pattern
attribute with an appropriate regular expression.
Note that there are new HTML5 input
elements for
telephone number and e-mail, but we cannot be sure all of our site
visitors will be using a browser that has implemented these features,
so using the pattern
attribute is currently a "safer"
alternative. Clearly it makes no sense to try to validate what goes
into either the
Subject: box or the Comments: box, but we
do require these two boxes to contain some input. The checkbox
requesting follow-up may or may not be checked. Unless all of these
requirements are met, the form data must not be submitted to the
server for processing.
A Note About the Feedback Form
You will note that if you submit the form and then go back to the form (to
make another submission, perhaps) or if there is a problem of some kind with
the submission and you want to go back to the form and start over, you may
have to "really" start over, in the sense that the values you previously
entered into the form may no longer be there. If this happens, it can
obviously be bit of a pain for the user. Browsers seem to be getting better
at "remembering" recent form data, so it may or may not be a problem. In any
case, as a web developer you can arrange that the form data is retained
after an attempted submission that may or may not have succeeded, and we
will see more about this later.
In addition to all of the directories and files from version 2 of your website, this third version must also have the following additions/changes:
scripts
subdirectory to get the
random daily quotation from the MongoDB database. This script replaces the
one that got the random daily quotation from the JSON file in the previous
version of your website.
pages
subdirectory containing your
feedback form, and a new PHP script file in your scripts
subdirectory to process the data from this form when it is submitted.
resources
subdirectory called
quotes_mongo.json
containing your quotes in the JSON format
that you used to load them into your MongoDB database. [Of course, once
the quotes have been so loaded, the file containing them is no longer
necessary, but since it is an "original" resource for your site, it should
be retained, and the resources
subdirectory would thus seem
to be the logical place to keep it.]
data
containing a new file called
feedback.txt
. This is the file that contains the
stored-on-disk information, in chronological order, of the feedback
information from every site visitor who filled out and submitted your
feedback form.
readme.txt
file, in the usual place, with the usual
contents.
Submit the required directories and files by copying them into the
submission03
subdirectory of the
submissions
subdirectory in the
public_html
directory of your personal Linux account
u##
, where the ##
are the last two digits
in your Linux account username for this course.
Be sure to develop outside the submission03
directory
and copy your directories and files to the
submission03
directory when you are ready to submit, so that
there is nothing in the submission03
directory but the
directories and files required for the submission. And be sure to test again
after the copy to make sure everything still works.
In the same directory as your my_business.php
,
issue the following Linux commands, which set up the required
subdirectory and file, with their necessary permissions, for
PHP to log user feedback submissions:
mkdir data cd data touch feedback.txt chmod 664 feedback.txt
uxx
is, of course, your
username):uxx@mail.cs.smu.ca
http://mail.cs.smu.ca/mail
. The message
you see at at this point will vary, depending on your browser.
uxx@mail.cs.smu.ca
and your
initial account password.
u50@mail.cs.smu.ca
Develop your files and directories in the directory
submissions/03
, and when you're finished, copy the contents of
this directory to submissions/submission03
and test/revise to
make sure everything is still working in the new location.
readme.txt
file in the home directory?
quotes_mongo.json
file in the
resources
subdirectory containing quotes in an appropriate
JSON format?
pages
subdirectory?
scripts
subdirectory?
data
subdirectory containing a
feedback.txt
file?
uxx
account, and eventually by the u50 account in the case of the marker) receive an e-mail confirmation of the feedback submission?
data/feedback.txt
file updated with this latest feedback
information? [Note that although the "business e-mail" will be to the
u50
account for testing purposes, the
feedback.txt
file will be the one in the account where the
website is located.]
readme.txt
file adequately describe the state of the
website?