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()"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.