Home      Products & Services      Contact Us      Links

WebHatchers will design & develop your site for you.

Website Menu Heaven: menus, buttons, etc.

Send us your questions.

site search by freefind

SEO, Google, Privacy
   and Anonymity
Browser Insanity
Popups and Tooltips
Free Website Search
HTML Form Creator
Buttons and Menus
Image Uploading
Website Poll
IM and Texting
   or Not MySQL
Personal Status Boards
Content Management
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS
Blog CMS
Customer Records
   Management CMS
Address Book CMS
Private Messaging CMS
Chat Room CMS
JavaScript Charts
   and Graphs

Free Personal Status Boards (PSB™)

Free Standard Free PSB

Free PSB Pro Version

Free Social PSB

Free Social PSB Plus (with Email)

Free Business PSB

Free Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement

Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

PHP Code for Delete Reply in Database

Content Management System: Blogs

The blog's reply deleting page whose code is on this web page is very simple. If your username matches the administrator's username, the replies table is consulted, and the topic which has the reply to delete has its id learned from a PHP GET statement and the reply id is also learned from a PHP GET statement, and the reply that has the a_id that belongs to this reply and the question_id that is this topic's id is dumped from the replies table of the MySQL db using the SQL DELETE FROM command.

On to the PHP code. As usual, we start with config.php, since without it, the MySQL-based blog would not be viable. You cannot relate to a db without knowing the magic words. Next, the security of the page is dealt with by ensuring the page visitor has the administrator's username. Note that the various pages on our blog app use both forms and URL query strings to transfer data between pages, so both POST and GET are checked for username, and if neither works, the visitor is sent to the login script. Not only is the username checked to ensure it is the administrator's username, the username is checked to make sure it has only 6 to 20 letters, numbers or underscore in it and no other characters—otherwise, it's off to the login script. If a hacker has put something nasty in the query string, he'll end up at the login script. All our blog app scripts have this same (almost) username checker at the top of the PHP section—except for the login script. We say "almost" because most pages (like this one) only allow the administrator access because most pages are about adding, deleting, or editing topics, replies, or categories. So, seeing if the username is the administrator's is in the user checker on most of these blog app pages.

The administrator's username is a bit silly, as you see. Feel free to change it (to AfDqC_1f3_DkI3j5k9N_ for example) when you register the administrator username and password, but you must use search and replace on ALL blog app pages searching for our silly name and replacing it with your not-as-silly name or you'll have more problems than a pregnant nun.

Next comes GETting the topic id and reply id gotten from the URL query string that brought us to this reply deleting page. Depending on which reply's Delete Reply link is clicked on the topic and replies viewing page, its corresponding reply id number and topic id number will be sent via query string (along with the username) to this blog reply deleting page and only this one reply will be vulnerable to deletion.

Finally, if your username matches the administrator's username, you'll be let into the script, and the reply, whose topic id is learned from a PHP GET statement and whose reply id is learned from a PHP GET statement, is dumped from the replies table, named blog_answer. The mysql_affected_rows() function finds out if deletions have occured and you get a message regarding the success or failure of this operation.

SAVE THIS PAGE AS: cms-delete-blog-answer.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Delete Blog Reply—Content Management System (CMS)</TITLE>
<meta name="description" content="Delete Blog Reply—Content Management System (CMS)">
<meta name="keywords" content="blogs,blog,Content Management System,Content Management System Articles,php,CMS,javascript, dhtml, DHTML">


$U=$_POST['username'];if (!isset($U)){$U=$_GET['username'];}
if (isset($U)&&preg_match("/[A-Za-z0-9_]{6,20}$/",$U)){if($U<>"DIRTY_dog_DROPPINGS_"){unset($U);}}else{unset($U);}
if (!isset($U)){echo '<script language="javascript">alert("You are not the Administrator. Go login again but you can only add replies or just read topics.");window.location="blog-login.php"; </script>';}



$sql="DELETE FROM $tbl_name WHERE question_id='$id' AND a_id='$aid'";
$result=mysql_query($sql) or die('Error ,deleting failed');
$rc = mysql_affected_rows();
if ($rc>0){echo '<script language="javascript">alert("The deleting was successfully accomplished.");window.location = "cms-view-blog-topic.php?id='.$id.'&username='.$U.'"; </script>';}
else{echo '<script language="javascript">alert("This reply does not exist. Please try again.");window.location = "cms-view-blog-topic.php?id='.$id.'&username='.$U.'"; </script>';}