Acubi Acubi - 5 months ago 44
PHP Question

How to close Browser Tab After Submitting a Form?

<?php
/* ... SQL EXECUTION TO UPDATE DB ... */
?>

<form method = "post"
action = "<?=$_SERVER['php_self']?>"
onSubmit= "window.close();">
...
<input type="submit" value="submit" />
<input type="reset" value="reset" />
</form>


I would like to close page after submitting the form. After running the above code the page is closed after clicking submit button, but the SQL doesn't execute.

Can anyone help me? Thanks in advance!

Answer
<?php    
    /* ... SQL EXECUTION TO UPDATE DB ... */

    echo "<script>window.close();</script>";
?>

and Remove the window.close() from the form onsubmit event

Comments