Main Menu

  Delete Sub-page Routines This module enables teachers to delete sub-pages that they have added.

When the teacher clicks the Delete Sub-Page (an icon of a document with a minus symbol) button on an edit page, this page will appear, asking for the owner to confirm their request to delete the page. If the confirmation is clicked, then the page is deleted and the owner is taken to the parent of the deleted page.

 
 
<?
//    -------------------------------------------------------    //
//                  D E L E T E   S U B - P A G E                //
//    -------------------------------------------------------    //
/*
    This set is designed to allow users to delete sub-pages
    that they have added to their web site.  Pressing the
    delete button will bring students to this page will will
    ask for confirmation and then delete the page and return
    the owner to the parent page.
    
*/
?>

			
Notes: This module consists only of comments. There are no commands, so it does not mater where this module goes in the page, or if it is there at all.
     
 
<?
//    -------------------------------------------------------    //
//                        Deleting Sub Pages                     //
//                        by adding preliminary                  //
//                        content.                               //
/*
    This module test for confirmation of the delete request.
    If the request has not been confirmed then the owner is
    asked to confirm or cancel the delete request.  If the
    request has been confirmed, the page is deleted and the
    browser is redirected to the parent page.
*/
?>
<?
if ($action == 'delete_confirmed')
	{

// Delete
    $db=mysql_connect
    ("host name","database name","database password");
    mysql_select_db
    ("database name",$db);
 		$sql="delete from page 
			where id = $id";
		$result =	mysql_query($sql); 

echo("
<HTML>
	<HEAD>
		<TITLE></TITLE>
		<meta http-equiv=\"refresh\" content=\"0;URL=page.php?id=$parent_id\">
	</HEAD>
<BODY BGCOLOR=#FFFFFF>
</BODY>
</HTML>	");
	}	else
	{
// Access		
    $db=mysql_connect
    ("host name","database name","database password");
    mysql_select_db
    ("database name",$db);
 		$result=mysql_query("select * from page where id = $id",$db);
		While ($myrow = mysql_fetch_row($result))
			{
				$title = $myrow[20];
				$parent_id = $myrow[27];
			}
echo("
<HTML>
	<HEAD>
		<TITLE></TITLE>
	</HEAD>
<BODY BGCOLOR=#FFFFFF>
<center>
	");
		if ($parent_id > 0)
			{
echo("
Are you sure you want to delete<br>$title<p>
<a href=delete_page.php?id=$id&action=delete_confirmed&
parent_id=$parent_id>Confirm</a> -- 
<a href=page_edit.php?id=$id>Cancel</a>
	");
			}	else
			{
echo("
This Page can not be Deleted<p>
<a href=page.php?id=$id>Return to the Page</a>
	");
			}
echo("
</center>
</BODY>
</HTML>
	");
	}
?>
			
Notes: This module checks to see if the delete request has been confirmed. If it has not, then it displays a message asking the owner to click Confirm to execute the delete request or Cancel to cancel the request.

If the request has been confirmed, the module deletes the page content from the database, and returns the owner to the parent page.

There are two occassions in this module where your database is accessed. Remember to replace the host name with the hostname of your server, the database name with the name of your database, and the database password with the password for your database.