[RESOLVED] PHP-JavaScript save to SQL and close?
I have two buttons in a pop-up window, a save and close...
HTML Code:
<input type="button" class="box" onClick="window.close()" value="Close Page" />
<input name="Save" class="box" type="submit" value="Save Record" />
PHP Code:
if($_POST['Save']){
mysql_select_db("ArborealClients", $con);
if (in_array("$lastname",$oneclient)){
mysql_query("UPDATE DB SET x='$y' WHERE a='$b' LIMIT 1");
}else{
mysql_query("INSERT INTO DB (x ) VALUES ('$y')");
}}
How can I combine the two so theres one button to save the information and then close the window?
Re: PHP-JavaScript save to SQL and close?
you should be able to just call window.close() onload of the <body> tag.
PHP Code:
<?php
//do php stuff.
?>
<body onload="window.close()">
<!-- blah -->
</body>
I think that could work.
Re: PHP-JavaScript save to SQL and close?
thanks I've done this...
PHP Code:
<body>
<!-- html code & button -->
<?php if ($_POST['save'])
echo "</body>";
echo "<body onload=\"window.close()\">";
?>
</body>