For this part of the project you need to provide forms for users to post and comment, validate the user data and store it in the database. Validation must be done using regular expressions.
Add a form to let the user post a new post. Make sure the form is accessible from the front page (and possibly from other pages, as a part of the menu bar, if any) to let the user post a new post. The post form should require a user to enter the following data:
When the server recieves the data, it must validate it as follows:
a
tags in the post:
posts with a large number of links are often spam. form
tag, for instance. You don't
need to make a full-proof checking system, just demonstrate how you
would allow some tags but not other ones. Write (in comments) what
is allowed in posts and what is not allowed. If the data did not pass validation on any of the counts, display the form with a meaningful error message to the user. Make sure to redisplay all entries that passed the validation so that they don't need to be retyped (we will see an example in class on how to do this).
After the data has been validated you need to add it to the database. Use your group login name and password to connect to the database.
mysql_real_escape_string
to put
appropriate escape characters before adding text fields to the
database (see the example of inserting data into the database
that we considered in class)The user should be able to comment on a post by clicking the "Comment on this" link of the post. The link should bring the user to a page with a form. Note that you need to pass the post ID (through a GET method) to the comment form. Since you need to pass it further to the php file that handles the comment form, you may either still use the GET method or include it as a hidden field in the form:
<input type="hidden" name="post_id" value="..."
where the value is the post ID. Then you can access it in the php file
that handles the form like this: $_POST["post_id"]
.
The rest of the comment form is similar to the post form. It requires the user to enter (at least):
You need to check the validity of both (you may use the same functions as you used for validating post data, in this case store the functions in a separate file and include the file in both files that handle forms).
After you have validated the data, store it in the database. Make
sure to increment the comment count in the wp_posts table and set the
user display name.
Test your forms carefully to make sure that all the data is stored
correctly and that the data is validated so that the incorrect data
does not get stored. Also make sure that when the user enters
incorrect or incomplete data, the form with wrong fields marked is
displayed.
Groups of three should have all three of their features implemented at least partially.
All groups are required to implement at least one additional feature (of your choice) for the final installment; groups of three are required to implement three features. Here are some suggestions:
This page is a part of CSci 1101 course web site.