Patrick's Lucky Dip - Adding Basic Feedback |
||
The ProblemI wanted to make the web site more interactive and offer visitors the opportunity to comment on what they found. My web provider only offered mysql and php support so I had to learn this in order to build the required functionality. Luckily I was able to learn from others. The SolutionI started by trawling the web and found some fairly sophisticated blogging php programs. These seemed to be overkill for what I needed, and I found the code too complex for a beginner to hack. I was at the city library with my kids when I spotted "PHP & MySQL for Dummies". A quick flick through showed that it had some good example code that I could borrow. Armed with this, I put together two php pages: one to display comments already entered and allow new comments to be logged, and another page to save the comments to the table I created in mySQL.
You can download both the feedback php page and the save feedback page. I created a second table in mySQL to list the pages for which I had enabled feedback. This isn't strictly necessary, but I find it a useful place to track which page id's relate to which pages. I plan to use it to track which pages get the most feedback and also to help identify which pages have had new feedback for me to review. Other possibilities include the adding of a login function: this would allow people to edit their own comments. To add feedback to a page, all that is required is the inclusion of the following code:
<iframe src="http://[my cgi server url]/feedback.php?page_id=10" frameborder=0 width=100% scrolling=auto height=100%></iframe>
Patrick Haston |
||