Hi,
I have the following code, which is a pop-up window used to enter data into a database.
When the user adds a new item the parent page is refreshed and the new item is displayed, then the user is given the option to add another item or close the window...if the user selects add another item, then the form will be displayed again, however, this time when the user adds the new item, by pressing the add button, the item actually goes into the database, but the parent page is not refreshed...
i cannot understand why the same button would refresh a page the first time, and then not perform the same funtion the second time?
can someone help....
thanks,
sp
here is my code....
<html><head><title>Add Business Section</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK REL=STYLESHEET TYPE="text/css" HREF="admin_CSS.css">
<body>
<script type="text/javascript">
<!--
myWindow = window.open(addbus2.php);
-->
</script>
<? require_once('db-include.ini'); ?>
<div id="adding">
<P><FONT SIZE=5><Center><B><h6>Add Business Section</h6></B></center></FONT></P>
<?
if (isset($_POST['submit'])) {
//double-up apostrophes
$_POST['bname'] = str_replace("'","''",$_POST['bname']);
$AddBS = "INSERT INTO BUSINESS_SECTION (business_section_name)
VALUES ('$_POST[bname]')";
$iStatement = @OCIParse($connection, $AddBS);
// verify that SQL is valid
$arrError = OCIError($iStatement);
if ($arrError['code'])
{
print $arrError['message'];
OCIRollback($connection);
exit;
}
@OCIExecute($iStatement, OCI_DEFAULT);
// make sure there were no errors with our query
$arrError = OCIError($iStatement);
if ($arrError['code'])
{
print $arrError['message'];
OCIRollback($connection);
exit;
}
OCICommit($connection);
?>
<center>
<h3><? echo $_POST['bname'], " " , "has been added to the Business Section table!"; ?></h3>
</center>
<form>
<table align="center">
<TR><TD><INPUT TYPE="submit" NAME="submit" VALUE="-ADD ANOTHER-"onClick="myWindow.location.reload(true); "></TD>
<TD><INPUT TYPE="submit" NAME="close" VALUE="-CLOSE-"onClick="window.close();"></TD>
</tr></table></form>
<?
}
else
{
?>
<FORM NAME="addbs" ACTION="addbus2.php" METHOD="POST">
<TABLE>
<TR><TD><h5>Business Section Name:</h5></TD><TD><INPUT TYPE="text" NAME="bname" SIZE=35></TD></TR></table>
<br>
<table align="center">
<TR><TD><INPUT TYPE="submit" NAME="submit" VALUE="-ADD-"onClick="window.opener.location.reload();"></TD>
<TD><INPUT TYPE="submit" NAME="close" VALUE="-CLOSE-"onClick="window.close();"></TD></TR>
</TABLE>
</FORM>
<? } ?>
</div>
</body>
</html>