I have a form that submits data and it stays on the same page using isset. See code below.
After it gets to the echo statement saying "Update successful", I want it to auto redirect to itself again so that I can enter another value straight away.
How can I do this? Currently, it gives me the error:
Warning: Cannot modify header information - headers already
<?php
if (!$submit)
{
// code to display form goes here
?>
<form name="form1" method="post" action="<? echo $PHP_SELF; ?>"
<p> </p>
<table width="200" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>TopicName1</td>
<td><input name="TopicName" type="text" id="TopicName"></td>
</tr>
<tr>
<td>MetaTitle</td>
<td><input name="MetaTitle" type="text" id="MetaTitle"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
<?
}
else
{
//form processor code goes here
$dbh=mysql_connect ("localhost", "alwaysac", "xxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("alwaysac_MyArticles");
mysql_query("insert into Articles(TopicName, MetaTitle) values('$TopicName', '$MetaTitle')");
//mysql_query("insert into Articles(TopicName) values('$TopicName')");
echo "Update successful.";
mysql_close($dbh);
header("Location: " . "peaadd.php1");
}
?>