Forum Moderators: coopster & phranque

Message Too Old, No Replies

How do I write results of order form to a file?

         

Marcia

8:40 am on Dec 6, 2000 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've got a form running that uses the host's secure server, and sends the input to the designated recipient(s)through email (uses Perl script in my cgi bin and sendmail).

What I need to do is have secure order forms that, when filled in, write the form input to a file instead. Then I need to have those results appear on a page in a legible format that has password protection to access it, with nothing more than an email notice sent that an order has been received, with no details (like credit card numbers, etc.)The order information can then be retrieved, and the order/billing info hand entered at ProPay.

There's "built-in" password protection in the control panel that can be used for any number of directories, but it's writing the results to a file that can be accessed rather than sent by email that I want to do.

Is there a "ready-made" that can do this, or one that can be modified easily? And, is there an alternative method for password protecting pages? Another concern is - what if several orders come in at once?

TIA, Marcia

sugarkane

10:37 am on Dec 6, 2000 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're using formmail (which is likely if it's a pre-installed script) then if you find the line:

open(MAIL,"¦$mailprog -t");

and change it to:

open(MAIL,">>/path/to/file/to/write/to");
flock MAIL,2;

this will append every incoming order to a single file instead of sending it by email, and will 'lock' the file just in case two orders come in at exactly the same time - one of them will be queued.

To be notified when an order is placed, you'd want to do something like:

open(MAIL,"¦$mailprog -t");
print MAIL "To: you@wherever.com\n";
print MAIL "From: whatever@wherever.com\n";
print MAIL "Subject: An order has been placed!\n\n";
print MAIL "some body text\n.\n";
close (MAIL);

at the end of the send_mail subroutine.

Hope this helps, it's untested ;)