Introduction to AMFPHP with Actionscript : Blogroll part 5
In this episode I’ll add a feature to allow users to submit their own blog to the blogroll. Of course you wouldn’t want people just adding entries and them going live so I’ll also update the blogroll table with an is_approved field. That way you will have control over who gets in and who doesn’t.
| view source |
Here is the updated Blogroll.php file used in this example. Note: I added a bit to the userAddBlog() method to send an email to the administrator any time an blog entry is added – commented out – and also used mysql_real_escape_string() to prevent code injection.
Don’t forget to update your blogroll table with the is_approved field and then set all existing rows to 1 with: UPDATE `blogroll` SET `is_approved` = 1;
Addendum: I forgot to add this to the video but the getBlogrollByPage() and getBlogrollCount() methods also need a slight update so that they will only select entries that have been approved. They now look like this:
function getBlogrollByPage( $start, $count ) {
$sql = "SELECT * FROM `blogroll`
WHERE `is_approved` = 1
LIMIT ".$start.", ".$count;
return mysql_query( sprintf( $sql ) );
}
function getBlogrollCount() {
$sql = "SELECT COUNT(*) AS 'count'
FROM `blogroll`
WHERE `is_approved` = 1;";
return mysql_query( sprintf( $sql ) );
}
The is_approved = 1 makes sure that only those blogs that have been approved by the administrator will show up.







