Jump to content

Can i save and print the form in php at the same time


leela

Recommended Posts

I'm no expert, but I think the way to do this would be to...

 

have the script that handles saving the form (whatever you have in action="" in the form tag) save the data to the database and also echo the html code that you want the invoice to look like to with the data filled in and with a javascript function in the head that sends the command to the user's printer to print.

 

SO! you have a couple of choice:

 

1. You can have the script that handles inserting the data query the database for that same data (which is probably bad practice), or simply use the same $_POST variables that you are adding to the database to echo into the printable page.

 

2. You could make the page "printer-ready" meaning it will print what the user sees on the screen which will be coded to look better on paper OR you can use @media print in your CSS and have it look good on the screen and on the page (changing the margins, getting rid any nav divs, change the font, etc)... There are plenty of sites that go over the different way's of going about the CSS option.

 

And as far as the page auto printing on load, you need to put this javascript somewhere in there:

 

onLoad="window.print()"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.