Hi, I'm following the tutorials in php and I came a cross a problem.

when I press submit button it wont take me back to add news page ! It just show me a blank page but when I refresh the page it loads the information I entered in the table (Display page).

code:





<?php
include('include/db.php');


if (isset($_POST['form_sub'])) {

if (isset($_POST['active'])) {
$active = $_POST['active'];
} else {
$active = 0;
}
/* //testing to see if all the forms are working
echo 'Here is the data we have to work with: <br>';
echo 'title:' . $_POST['title'] . '<br>';
echo 'content:' . $_POST['content'] . '<br>';
echo 'date:' . $_POST['date'] . '<br>';
echo 'active:' . $active . '<br>';
*/
$query = 'INSERT INTO event(
title,content,date_added,active
) VALUES (
"' . $_POST['title'] . '",
"' . $_POST['content'] . '",
"' . $_POST['date'] . '",
"' . $active . '"
)';

if (!mysql_query($query,$db_link)) {//checking if its working
echo mysql_error();
exit;
}

header('Location:'.$_SERVER['PHP_SELF']);
exit;
}
?>



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>




<p>
<?php
if (isset($_GET['add'])) {
?>
</p>

<p>&nbsp; </p>
<form id="form1" name="form1" method="post" action="<?= $SERVER['PHP_SELF'] ?>">
<table width="500" border="1" cellspacing="1" cellpadding="3">

<tr>
<td>Title</td>
<td><input name="title" type="text" id="title" /></td>
</tr>
<tr>
<td>Content</td>
<td><label for="content"></label>
<textarea name="content" id="content" cols="45" rows="5"></textarea></td>
</tr>

<tr>
<td>Date Added</td>
<td><input name="date" type="text" id="date" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="active" type="checkbox" id="active" value="1" />
<label for="active"></label>
Active </td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="form_sub" id="form_sub " value="Submit" /></td>
</tr>
</table>
</form>
<p>
<?php
} else {
?>
<a href="<?= $_SERVER['PHP_SELF'] ?>?add=1">Add Event</a></p>
<table width="100%" border="1" cellspacing="3" cellpadding="3">
<tr>
<td bgcolor="#CCCCCC"><div align="left">Title</div></td>
<td width="65" bgcolor="#CCCCCC"><div align="center">Active</div></td>
<td width="65" bgcolor="#CCCCCC"><div align="center"></div></td>
<td width="65" bgcolor="#CCCCCC"><div align="center">Delete</div></td>
</tr>

<?php
$query = 'SELECT * FROM event ORDER BY event_id DESC';
$result = mysql_query($query, $db_link);

while ($row = mysql_fetch_assoc($result))
{

?>

<tr>
<td>&nbsp;<?= $row['title']?></td>
<td>&nbsp;<?= $row['active']?></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<?php
}
?>

</table>
<p>&nbsp;</p>
<p>



<?php
}// end main if
?>
</p>



</body>
</html>