Reputation: 448
When I Click on a link it Redirects me to a php
page whose main objective is to save data into MySQL
but nothing more than that. So I want this page to close by itself once it is done saving the data in to the database. How can I do that ? any pointers would be great.
Upvotes: 0
Views: 397
Reputation: 387
Unless you're talking about a genuine popup (and with tabbed browsing and mobile devices these days, who knows how the page is viewed) I think the best method would be to redirect to another page after execution by using header("Location:http://www.mysite.com/done.php");
. Preferably something that tells the user if the execution was successful.
Upvotes: 0
Reputation: 4321
First, remember that PHP is a server-side language, and has completely nothing to do with the browser. It will only output code to the browser that will be interpreted by the browser. Javascript is what interacts with the browser.
However, to let you know, using Javascript, you won't be guaranteed that the function will actually execute for a variety of reasons, namely that the browser usually confirms with the user whether the user is okay with the window being closed.
Here is the code:
<script type="text/javascript">
window.close();
</script>
Upvotes: 2
Reputation: 96
put this Code at the end of your page. When this script is executed your tab will be closed.
<script type="text/javascript">
window.close();
</script>
Upvotes: 3
Reputation: 5337
You could the Javascript window.close method to do that, this is not a job for PHP.
Upvotes: 0