Main Menu

  Add Sub-page Routines This module enables teachers to add sub-pages to their initial web pages and even sub-pages to sub-pages. The result can be a miniature web site, representing a rich set of resources for classroom stakeholders.

When the teacher clicks the Add Sub-Page button on an edit page, this page will appear, asking for the owner's name, and the title of the page. It asks for the owner's name, because the teacher may be delegating the management of this page to a student or assistant. When the information has been entered, the edit version of the new page will appear so that the teacher can start populating the page with content.

 
 
<?
//    -------------------------------------------------------    //
//                        A D D   S U B - P A G E                //
//    -------------------------------------------------------    //
/*
    This set is designed to allow users to create additional
    web pages that will be added as a links from the page
    that they are added from.  The result is a mini-website,
    and additional mini-websites within the original.
    
*/
?>

			
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.
     
 
<?
//    -------------------------------------------------------    //
//                        Establishing new web page              //
//                        by adding preliminary                  //
//                        content.                               //
/*
    This module tests for readiness to add new page.  If
    the information has been added and the submit button
    was clicked, then this routine will add the page with
    the content.
    
    This module will also check for the id of the new page
    and redirect to the edit version of the added page.
    
    Note: do not add any codes, php or html that will output
    content to the browser before this routine.
*/
if ($mode == 'add')
    {
//                        accessing password        //
// Access        
    $db=mysql_connect
    ("host name","database name","database password");
    mysql_select_db
    ("database name",$db);
        $result=mysql_query
        ("select * from page where id = $parent_id",$db);
        While ($myrow = mysql_fetch_row($result))
            {
                $password = $myrow[29];
            }

        $code = time();
// Add
    $db=mysql_connect
    ("host name","database name","database password");
    mysql_select_db
    ("database name",$db);
            $sql="insert into page
                    (    name_contact,
                        page_title,
                        parent_id,
                        code, 
                        password)
            values    (    '$name_contact',
                        '$page_title', 
                        '$parent_id',
                        '$code',
                        '$password')";
            $result = mysql_query($sql);
// Access        
    $db=mysql_connect
    ("host name","database name","database password");
    mysql_select_db
    ("database name",$db);
        $result=mysql_query
        ("select * from page order by id desc",$db);
        While ($myrow = mysql_fetch_row($result))
            {
                if ($myrow[28] == $code)
                    {
                        $id = $myrow[0];
                        break;
                    }
            }
Header("Location: page_edit.php?id=$id");
    }
//                                                               //
//    -------------------------------------------------------    //
?>

			
Notes: This module is ignored the first time that this page is loaded (upon initial clicking of the Add Sub-Page button on the edit page. When the teacher enters the owner's name and page title, and clicks the submit button, this page will be re-loaded, the information checked and added to the database, and the teacher will be forwarded to the edit version of the new page.

It is important that this module be placed at the top of the page code. There should be no HTML tags and no blank links above or within this code.

     
 
<?
//    -------------------------------------------------------    //
//                    Form for Submitting New Sub-Page           //
/*
    This module will display a form for submitting pre-
    liminary content for addition of a sub-page for the
    current page.
*/

echo("
        <form    action=add_subpage.php
                method=post>
            Owner's Name:
                <input    type=text
                        size=30
                        name=name_contact
                        value='$name_contact'><br>
            Page Title:
                <input    type=text
                        name=page_title
                        value=$page_title>
                <input    type=hidden
                        name=mode
                        value='add'>
                <input    type=hidden
                        name=parent_id
                        value=$parent_id><hr>
                <input    type=submit
                        value='Add Page'>
        </form>
    ");
//                                                               //
//    -------------------------------------------------------    //
?>        
			
Notes: This module generates the form for entering the owner's name and page title. This code can be inserted into a prepared web page, but it works well alone. Simply place the appropriate HTML tags above this module and below. Here are the tags you would place above the script:
<html>
<head>
<title>Password Checker</title>
</head>
<body>

Place the password checker script here, then follow with:

</body>
</html>

I will sometimes place the script inside of a table with on cell, setting the table to 100% height and 100% width. Then set the cell to center align and middle valign. The table code would look like this:
<table width=100% height=100%>
<tr>
<td align=center valign=middle>

put script here

</td>
</tr>
</table>