0

I have 3 php files: view.php, edit.php and edit2.php.

view.php is where I view the content of my database. I use edit.php to enter new data and it's a small window that in which I type in a content I want to include in my db.
Then, I pass all of the data to edit2.php which doesn't display anything but only has implemented MySQL queries.

Now I would like to have something like this:

I'm on view.php. I click a button, edit.php opens as a new, small window. I enter the data, click SUBMIT button, everything is sent to edit2.php but at the same time the window is closed and view.php is refreshed.

I would be thankful if you could help. Thanks in advance.

whiteestee
  • 301
  • 1
  • 4
  • 12

3 Answers3

4

You can use the js function window.opener.location.reload().There is no need of ajax for refreshing the page..Simple js is enough.

Avinash Babu
  • 6,171
  • 3
  • 21
  • 26
0

Add following code to your edit.php

    <script>
    window.onunload = refreshParent;
    function refreshParent() {
        window.opener.location.reload();
    }
   </script>
Ajitha Ms
  • 545
  • 5
  • 18
  • This will open view.php in the small (I called it "child") window and I want to close the child window and at the same time refresh the parent window. – whiteestee Jul 28 '14 at 09:16
  • you mean after execution of edit2.php, you want to open view.php as new window right?? – Ajitha Ms Jul 28 '14 at 09:18
  • No. I'm on view.php. I click a button, edit.php shows as a new, small window. I type in what I want to include in my db, click "save" (or whatever button), everything is sent via html post method to edit2.php, but at the same time this small window is closed and the main, big window is refreshed. – whiteestee Jul 28 '14 at 09:20
  • ok.. I understand.. Better you can send request to edit2.php and get success from edit2.php – Ajitha Ms Jul 28 '14 at 09:22
  • if(success){ close.edit2.php and... refresh view.php } – Ajitha Ms Jul 28 '14 at 09:23
  • http://stackoverflow.com/questions/10792408/open-popup-and-refresh-parent-page-on-close-popup refer... – Ajitha Ms Jul 28 '14 at 09:27
0

You may use header('Location: view.php'); at the end of your edit2.php

Ashish
  • 188
  • 1
  • 2
  • 11
  • I already answered this, using header("location: view.php"); will open view.php in the small window and I want to close the small window and refresh the main (parent) window. – whiteestee Jul 28 '14 at 09:19