making sure data inserted before closing
Moderator: General Moderators
making sure data inserted before closing
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.
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.
I hope you understood the simple example.
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>