Objective:
- Add search capability to the site based on a database backend which searches all documents on the site based on their Meta description tag.
- Add a feedback mechanism to all assignments pages, enabling logged in users to post comments on my documents, store them on a database, and display them on the bottom of the document they were posted on.
The obstacles:
Since I had never done any of those things, I had to take some time to analyze everything that I had to do. First I worked on the search engine and looked up references to learn what the best approach was so I could get it done. I did the same thing with the feedback mechanism.
The solution:
For the search engine, I started by creating a table in my database. It contains 3 fields to hold the requested information (title, description, link) plus an ID number that was set as the primary key with auto increment, so I could sort by ID just in case I had the same word in more than one page. I placed the search box and the search button in the header include file, so it would be present in all of the pages.
I then used Dreamweaver to assist me with the PHP part of the code and created connections and recordsets so I could have the page communicate with the database.
As for the feedback mechanism, I did basically the same thing as far as the database/table goes, except that the table contains six fields (id, site, name, comments, date, subject) to hold the information.
I also had to make sure that the form would be available only for the users that were logged in. For that, I just added this piece of code in my header include :
<?php if (!empty($_SESSION['MM_Username'])){
$logged = "true"; ?>
<a href="<?php echo $logoutAction ?>">Log Out</a> |
<a href="/english/cit235/admin/index.php">Administrator</a>
<?php
}
else {
$logged = "false"; ?>
<a href="/english/cit235/clients/login.php">Login</a> | <a
href="/english/cit235/clients/jb_test2.php">Register</a><br />
<?php
}
?>
And then, in the comments page I added a code that checks to see if the user was logged in or not.

