Hello friends,
I am building a program for an online store that prints packing slips for all of the orders. Because of the nature of the Internet and the problems that can occur when a script starts to when it ends, I must have a fool proof way of checking wether or not all pages have succesfully printed.
So far, I have been able to create the packing slips perfectly for printing! For this, I am exited. But what happens when near the end of the script, my Internet connection goes down and I can't finish loading the page?
The second to last thing that happens in the script is a javascript function is called that tells the user how many pages have been sent to the printer (there is no print window, it justs gets sent right away), then after that, I finish the transaction for the postgresql database (I have been inserting the packing slips into the DB as they are generated). If my Internet connection fails before the javascript function is called, will the script continue?
Here is my code at the end of the function:
<?php
// all of the code that inserts the packing slips into the DB is here
// Would the following code get executed if I lost my Internet connection at this point
?>
<script defer>
// call some javascript
alert("This is the alert to notify the user of the pages being sent to the print");
</script>
<?php
// finish the transaction
$result = pg_exec($dbh,"COMMIT");
I hope you guys can understand what I am trying to do. If you need any more info or have other suggestions, please let me know.
-Sean