View Full Version : update database on print?

03-06-2012, 03:55 PM
I've got a simple script that generates a button that sends to the printer when clicked. But a totally new thing to me is finding a way to update a "printed_unprinted" field in the database for that item. Anyone have experience with this?

Right now, I just have:
<style type="text/css" media="print">
@page { size:8.5in 11in; margin: 1cm }
.printbutton {
visibility: hidden;
display: none;

document.write("<input type='button' " +
"onClick='window.print()' " +
"class='printbutton' " +
"value='Print This Page'/>");

I assume I could reference a php file? Just something quick like:


$id = mysql_escape_string($_POST['printed']);

$query_update = "UPDATE tbl_registration SET reg_hardcopied = '1' WHERE reg_id = '$id'";
$dberror = "";
$ret = mysql_query($query_update);
//back to referrer



03-06-2012, 08:18 PM
There are several other ways to print without pressing a button. There's no way to tell if someone printed something or not.