
How do I automatically print the results of an HTML FORM?
Dave, I remember reading your book Creating Cool Web HTML 4 Web Pages and seeing a sample about a sub shop where online customers could order sandwiches...
Can you help me find a script that will take FORM information and upon submit, send it directly to a network printer? This is for a local courier service I am building a site for and I would like to offer them real time, print outs of web based delivery orders. Hmmm.... I'm not sure that you actually want a form on your Web site that feeds directly to a printer since I would worry that it could be abused and you could end up wasting reams of paper and having a hard time finding the legitimate courier orders in the piles. An alternative approach would be to have all the requests queue up in some sort of rudimentary database then have a simple review procedure where someone could eyeball each entry and, if they're valid and legit, print them and distribute them as a courier work order. However, that's not what you asked me, so let me solve the problem you posed. I would create a form that produces a printout by setting up an email address on my server that feeds directly to a printer. For example, "printout@yourhost.com". On a Unix or Linux system, that might well be as simple as adding a line like this to your /etc/aliases file: printout : "|/bin/lpr" On a Mac or PC you'd need to get a bit further into scripting to have as neat and elegant a solution. With that in place, you can use a simple form to email CGI script, of which there are many available and probably one already installed on your Web hosting system. Simply point the script to the printout address and you should be good to go. If you do use this approach, you'll want to be sure that the HTML form does not include the email address, even as a hidden field. The form shouldn't have any email addresses embedded within it because that information can be much more safely stored in the CGI script itself, away from prying eyes and spammer's email harvesting tools. I hope this helps you out. Good luck!
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized:
CGI Scripts and Web Site Programming
(Article 3844)
Tagged: Previous: Does Paypal have a merchant referral program? Next: Are Explicit Copyright Notices Necessary for Weblogs and Web Pages? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. Dave, I actually have an additional question to this post. I was wondering if you have happen to try this with an Exchange 2003 server? This is what my company uses as a email server and I was curious if you knew whether or not it did in fact work properly. Thank you. Posted by: JeremyB at January 7, 2005 12:10 PMI haven't worked with Exchange server, but it strikes me that you can probably use ANY email program and just create a special ruleset that matches these incoming messages and automatically prints them to the local printer. You'd need to leave the computer running and the mail program grabbing email every so often, but I think that might be the easiest of all solutions, actually. No custom CGI work involved, and no monkeying with the sendmail aliases file either. Posted by: Dave Taylor at January 7, 2005 7:49 PMIn this page when you place the mouse over the underlined words a small window appears, can u please tell me how to do that I shall eagerly be waiting for your email Thanking you in advance Shiram, the specific system I have here is the Kontera advertising network, but generally, it's just a CSS layer that's transparent until you "onMouseOver" the link. Complicated, but not terribly so... Posted by: Dave Taylor at February 13, 2007 9:35 AMHi Dave We need to generate a web page that will print to a local printer automatically when the user clicks on a "Print" link on our page. To put it another way, we'd like to automate the user interaction associated with the print dialogue. If necessary, we could create a small .exe file installed on the client computer. Any thoughts? Thanks, I have a lot to say, but ...
I do have a comment, now that you mention it!
|
Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|