Help,create new page is not coming up

My name is taiwo, i am creating a content management system using kevin skoglund video tutorial of lynda.com, my “create new page” Page refuse to come up, wen i click on d link, it redirects me to content.php. here is the edit_subject.php page that contains the link(marked in red) to the create new page(new_page.php).


<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php
		if (intval($_GET['subj']) == 0) {
			redirect_to("content.php");
		}		
		if (isset($_POST['submit'])) {
			$errors = array();
			
			$required_fields = array('menu_name', 'position', 'visible');
			foreach($required_fields as $fieldname) { 
			if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && !is_numeric($_POST[$fieldname]))) {
					$errors[] = $fieldname;
			}
		}
			$fields_with_lengths = array('menu_name' => 30);
			foreach($fields_with_lengths as $fieldname => $maxlength) {
			if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname;}
			}
				if (empty($errors)) {
					//perform update								
				$id = mysql_prep($_GET['subj']);
				$menu_name = mysql_prep($_POST['menu_name']);
				$position = mysql_prep($_POST['position']);
				$visible = mysql_prep($_POST['visible']);
				
				$query = "UPDATE subjects SET
							menu_name = '{$menu_name}',
							position = {$position},
							visible = {$visible}
							WHERE id = {$id}";
							$result = mysql_query($query, $connection);
							if (mysql_affected_rows() == 1) {
								// Success
								$message = "The subject was succesfully updated.";
							} else {
								// Failed
								$message = "The subject update failed.";
								$message .= "<br />". mysql_error();
						}
				} else {
					// Errors occurred
					$message = "There were " . count($errors) . " errors in the form";
				}
								
			}	// end: if (isset($_POST['submit']))
?>
<?php find_selected_page(); ?>
<?php include("includes/header.php"); ?>
			<table id="structure">
			<tr>
				<td id="navigation">
			<?php echo navigation($sel_subject, $sel_page); ?>
				</td>
				<td id="page">
				<h2>Edit Subject: <?php echo $sel_subject['menu_name']; ?></h2>
                <?php if (!empty($message)) {
						echo "<p class=\\"message\\">" .  $message . "</p>";
				} ?>
                <?php
				// output a list of the field that had errors
					if (!empty($errors)) {
						echo "<p class=\\"errors\\">";
						echo " Please review the following fields: <br />";
						foreach($errors as $error) {
							echo " - " . $error . "<br />";
						}
						echo "</p>";
					}
				?>
                <form action="edit_subject.php?subj=<?php echo urlencode($sel_subject['id']); ?>" method="post">
                	<p>Subject name:
                		<input type="text" name="menu_name" value="<?php echo $sel_subject['menu_name']; ?>" id="menu_name" />
                     </p>
                     <p>Position:
                     	<select name="position">
                   		  <?php
					 		$subject_set = get_all_subjects();
						    $subject_count = mysql_num_rows($subject_set);
					 		// $subject_count + 1 bcos we are adding a subject
							 for($count=1; $count <= $subject_count+1; $count++) {
								 echo "<option value=\\"{$count}\\"";
							 	if ($sel_subject['position'] == $count) {
								echo " selected";
							 }
								 echo ">{$count}</option>";
					 		}
					 	?>
                     	</select>
                     </p>
                     <p>Visible:
                     		 <input type="radio" name="visible" value="0"<?php if ($sel_subject['visible'] == 0) { echo " checked"; } ?> /> No
                     		 &nbsp;
                    		 <input type="radio" name="visible" value="1"<?php if ($sel_subject['visible'] == 1) { echo " checked"; } ?> /> Yes
                   	     </p>
                    	 <input type="submit" name="submit" value="Edit Subject" />
                    
                    	&nbsp;&nbsp;
                        <a href="delete_subject.php?subj=<?php echo urlencode($sel_subject['id']); ?>" onclick="return confirm('Are you sure?');">Delete Subject</a>
                     </form>
                     <br />
                     <a href="content.php">Cancel</a>    
						<div style="margin-top: 2em; border-top: 1px solid #000000;">
                    <h3>Pages in this subject:</h3>
                    <ul>
                  <?php
				  $subject_pages = get_pages_for_subject($sel_subject['id']);
				  while($page = mysql_fetch_array($subject_pages)) {
					  echo "<li><a href=\\"content.php?page={$page['id']}\\">
					  {$page['menu_name']}</a></li>";
				  }
				  ?>
                  </ul>
                  <br />
                 [COLOR="Red"]<a href="new_page.php?subj=<?php echo $sel_subject['id']; ?>">Add a new page to this subject</a>[/COLOR]
					</div>
		</td>
	</tr>
</table>
<?php require("includes/footer.php"); ?>


here is the code for the new_page.php note the page-form.php required in the code below


<?php require_once("includes/session.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php confirm_logged_in(); ?>
<?php
		// make sure the page id sent is an integer 
		if (intval($_GET['page']) == 0) {
			redirect_to("content.php");
		}		
		
		include_once("includes/form_functions.php");
		
		// START FORM PROCESSING
		// only execute the form processing if the form has been submitted
		if (isset($_POST['submit'])) {
			// initialize an array to hold our errors
			$errors = array();
			
			//perform validations on the form data
			$required_fields = array('menu_name', 'position', 'visible', 'content');
			$errors = array_merge($errors, check_required_fields($required_fields));
			
			$fields_with_lengths = array('menu_name' => 30);
			$errors = array_merge($errors, check_max_field_lengths($fields_with_lengths));
					
				// clean up the form data before putting it in the database	
				$id = mysql_prep($_GET['page']);
				$menu_name = trim($_POST['menu_name']);
				$position = mysql_prep($_POST['position']);
				$visible = mysql_prep($_POST['visible']);
				$content = mysql_prep($_POST['content']);
				
				// Database submission only proceeds if there were NO errors.
				if (empty($errors)) {
				$query = "UPDATE pages SET
							menu_name = '{$menu_name}',
							position = {$position},
							content = '{$content}'
							WHERE id = {$id}";
					$result = mysql_query($query);
					// test to see if the update occurred
							if (mysql_affected_rows() == 1) {
								// Success!
								$message = "The page was succesfully updated.";
							} else {
								// Failed
								$message = "The could not be updated.";
								$message .= "<br />". mysql_error();
						}
				} else {
					if (count($errors) == 1) {
					$message = "There were was 1 error in the form.";
				} else {
					$message = "There were" . count($errors) . " errors in the form.";
					foreach($errors as $value)
						$message = "\
".$message.$value."\
";
					echo $message;
					return;
				}
			}
				// END FORM PROCESSING
		}	
?>
<?php find_selected_page(); ?>
<?php include("includes/header.php"); ?>
			<table id="structure">
			<tr>
				<td id="navigation">
			<?php echo navigation($sel_subject, $sel_page, $public = false); ?>
				<br />
			<a href="new_subject.php">+ Add a new subject</a>
				</td>
				<td id="page">
				<h2>Adding New Page</h2>
                <?php if (!empty($message)) {echo "<p class=\\"message\\">" .  $message . "</p>";} ?>
                <?php if (!empty($errors)) { display_errors($errors); } ?>
                <form action="new_page.php?subj=<?php echo $sel_subject['id']; ?>" method="post">
                	<?php $new_page = true; ?>
					[COLOR="Red"]<?php include "page_form.php" ?>[/COLOR]
                    	 <input type="submit" name="submit" value="Create Page" />
                     </form>
                     <br />
                     <a href="edit_subject.php?subj=<?php echo $sel_subject['id']; ?>">Cancel</a></br >              
		</td>
	</tr>
</table>
<?php include("includes/footer.php"); ?>

here is the code for the page_form.php


<?php require_once("includes/session.php"); ?>
<?php confirm_logged_in(); ?>
<?php // this page is included by new_page.php and edit_page.php ?>
<?php if (!isset($new_page)) {$new_page = false;} ?>

<p>Page name: <input type="text" name="menu_name" value="<?php echo $sel_page['menu_name']; ?>" id="menu_name" /></p>

<p>Position: <select name="position">
	<?php
		if (!$new_page) {
			$page_set = get_pages_for_subject($sel_page['subject_id']);
			$page_count = mysql_num_rows($page_set);
		} else {
			$page_set = get_pages_for_subject($sel_subject['id']);
			$page_count = mysql_num_rows($page_set) + 1;
		}
		for ($count=1; $count <= $page_count; $count++) {
			echo "<option value=\\"{$count}\\"";
			if ($sel_page['position'] == $count) { echo " selected"; }
			echo ">{$count}</option>";
		}
	?>
    	</select></p>
    <p>Visible:
    <input type="radio" name="visible" value="0"<?php
	if ($sel_page['visible'] == 0) { echo " checked"; }
	?> /> No
    &nbsp;
    <input type="radio" name="visible" value="1"<?php
	if ($sel_page['visible'] == 1) { echo " checked"; }
	?> /> Yes
    </p>
    <p>Content: <br />
    <textarea name="content" rows="15" cols="70"><?php echo $sel_page['content']; ?>
	</textarea>
    </p>

there is number behind it…just don’t know why it wudn’t work, i i have attached the whole pages and the sql script(widget_corp.zip), u can put it up and see if u can help me fix it. thanks spike i appreciate ur response

Hi taiwo and welcome to Sitepoint.

on the page edit_subject.php, when you hover over the link what does it say in the status bar of the browser?
It should be something like


new_page.php?subj=1

if there is no number after subj= then the script redirects to content.php


if (intval($_GET['subj']) == 0) {
            redirect_to("content.php");
        }  

If subj is missing from the link it will redirect so check that the $sel_subject[‘id’]; is set.
if not then you need to check your sql query that retrieves the data.