Code breaking

please the contents.php, is breaking the edit_page link, i am thinking its a loop swhere, but i cant figure it out.when i ckick on the edit_page link, it redirects me to contents.php


<?php require_once("include/connection.php"); ?>
<?php require_once("include/functions.php"); ?>
<?php find_selectedpage(); ?>
<?php include("include/header.php"); ?>
<div id="navigation">
<?php echo navigation($select_subject, $select_page); ?>
		<br />
		<a href="new_subject.php">+ Add a new subject</a>
	</ul>
</div> <!--end of navigation div -->

<div id="bodycontent">
<?php if (!is_null($select_subject)){// subject selected ?>
 <h2> <?php echo $select_subject['menu_name']; ?></h2>
 <?php } elseif (!is_null( $select_page )) { // page selected ?>
 <h2> <?php echo $select_page['menu_name']; ?></h2>
 <p><?php echo $select_page['content']?></p>
 <p><a href="edit_page.php">Edit this page</a></p> <br />
 <?php } else { // nothing selected ?>
 <h2> Select a subject or page to edit </h2>
 <?php } ?><br />
 
</div>
</div>
<?php require("include/footer.php"); ?>


<?php require_once("include/connection.php"); ?>
<?php require_once("include/functions.php"); ?>
<?php 
if (intval($_GET['page']) == 0) {
			redirect_to('contents.php');
}

include_once("include/form_functions.php");

// start form processing
// only execute the form processing if the form has been submitted  
if (isset($_POST['submit'])) {
// initialise 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_lenghts = array('menu_name' => 30);
     		$errors = array_merge($errors, check_max_field_lenghts($fields_with_lenghts));
     		
    
     //update
   			   $id = mysql_prep($_GET['page']);
     			$menu_name = trim(mysql_prep($_POST['menu_name']));
				$position = mysql_prep($_POST['position']);
				$visible = mysql_prep($_POST['visible']);
				$content = mysql_prep($_POST['content']);
				if (empty($errors)) {
				$query = "UPDATE pages SET
							menu_name = '{$menu_name}',
							position = {$position},
							visible = {$visible}
							content = '{$content}'
						WHERE  id = {$id}";
					$result = mysql_query($query, $connection);
					if (mysql_affected_rows() == 1) {
					// Success
					$message = "The page was succesfully updated.";
					} else {
					//failed
					$message = "The page was not succesfully updated.";
					$message .= "<br />". mysql_error();
					}
     }else{
     if (count($errors) == 1) {
     			//error occured
     			$message = "There  was 1 error  in the form.";
     }else{
     $message = "There were " . count($errors) . " errors in the form.";
     }
   
} // end of if (isset($_POST['submit']))
}
?>
<?php find_selectedpage();  ?>
<?php include("include/header.php"); ?>
<div id="navigation">
		<?php echo navigation($select_subject, $select_page); ?>
		<br />
		<a href="new_subject.php">+ Add a new subject</a>
</div> <!--end of navigation div -->

<div id="bodycontent">
		<h2>Edit page: <?php echo $select_page['menu_name'];?></h2>
		<?php if (!empty($message)) {
		echo "<p class=\\"message\\">" . $message . "</p>";
		} ?>
		<?php
		if (!empty($errors)) { display_errors($errors); } ?>
		
		<form action="edit_page.php?page=<?php echo $select_page['id']; ?>
		" method="post">
		<?php include "page_form.php" ?>
 <input type="submit" name="submit" value="Update page" />
   &nbsp;&nbsp;
   			<a href="delete_page.php?page=<?php echo
   $select_page['id']; ?>" onclick="return confirm('Are you
   sure?');"> Delete Subject</a>
   </form>
   <br />
   <a href="contents.php?page=<?php echo $select_page['id']; ?>">Cancel</a><br />
</div>
<?php include("include/footer.php"); ?>

Your code doesn’t need the opening and closing PHP tags at the top.

This looks like why you’re being redirected:


if (intval($_GET['page']) == 0) {
            redirect_to('contents.php');
} 

If you’d like some personal help, please let me know via PM. I’d be happy to help.