making sure data inserted before closing

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
thrice
Forum Newbie
Posts: 4
Joined: Fri Oct 24, 2003 4:30 pm

making sure data inserted before closing

Post by thrice »

hey i'm very new to php, and i'm trying to make a guestbook for my webpage. in the guest book i have an image that you click to open up a popup called gstbkinsert.php3 that has a field to insert your username and then a field underneath it to insert your comment. the problem is that i would like the pop up to close after its submitted, but only after its confirmed that the database recieved the data. it seems to only work most of the time if i have the window close onSubmit. how would i go about doing this? i've tried looking on google and stuff but i didn't really know how to word what i was looking for. anways, any help would be really appreciated.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

I thought of...
Use a javascript function to close the window. Then, after verifying that the different fields submitted are correct and/or accepted by the database, use something similiar as described below.

Code: Select all

<html>
<?php
 if (isset($_POST['foo']) and !empty($_POST['foo'])) {
     // check againt database here and do whatever to fi your needs...
    echo 'body tag goes here using onload=close_window() javascript';
 } else {
    echo 'body tag here, a normal one';
 }
?>
<form method="post">
 <input type="text" name="foo" />
 <input type="submit />
</form>
</body>
</html>
I hope you understood the simple example.
Post Reply