I've written a php script that displays a summary table with certain select information from a database table. It has a "view" button next to each row, which takes the user to a printable form with the complete information from the table on it. There is a portion on this form where the user can add more information to the form. The user clicks a button on the form, and a small window pops up, with a text area and a submit button. It all works fine and dandy, the information gets submitted to the table, and the little window dissapears. Only problem is, you have to refresh the page to see the data relfected on the screen.

My qustion is, how can I get it to automatically refresh that page so that the information will show, without them having to resend the data from the table? Here's the code for the popup window:

<?

echo "<img src=\"someimage.jpg\"></img><br>";
echo "<br>
Type your notes below and click \"Submit.\"
  <form method=post action=update_notes.php>
  <textarea name=\"notes\" rows=\"5\" cols=\"30\"></textarea><br>
  <input type=hidden name=request_id value=" . $_POST['request'] . ">
  <input type=submit value=submit>
  </form>";
?>

As you can see, it uses some information from the previous page to tell the mysql database which row to post the data on.

The page I want reloaded is called print_forms.php. I found some javascript that will automatically reload it, but without resubmitting the php data to it, the form comes up empty.

So somehow I was think that when the user clicks that submit button, it would post the notes to "update_notes.php", but then it would also reload the "print_forms.php" page while passing the requestid to it, so it knows what data to load it with. Ideas?

I know I've been mostly a leech on this forum, and haven't been able to contibute much yet. But I promise as I get more experienced I will contribute! Thanks for all your help!

Recommended Answers

All 2 Replies

Hi Nathanpacker,

This is actually a JavaScript question, and yes is possible. You just have to put a piece of javascript on the child window, that reloads the parent window with the url parameters you want.

The code looks ssomething like:

<script>
window.opener.location.href = 'http://example.com?param=value';
</script>

Thanks. Guess I'll have to brush up on some javascript and learn how to set those parameters.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.