Hi,
If I was you I would probably devide your application in 2 parts. One part is responsible for getting the user data and storing it in your database. This is the part you probably already have developed.
The second part is a script that runs from the command line ( I assume your website is hosted on a linux server? ). The script language can be PHP, Perl or whatever. This script checks periodically using crontab (say every 2 or 5 minutes or so) if there are any orders in your database. If there are new orders it creates the orderfile and sends it via sftp (and sets in your database that the order was send to the third party).
This approach needs you to have some (administration) privileges, like the ability to set crontab and use sftp. When you are on a shared server this could sometimes be a problem.
There are several reasons why I would use this approach. You can (and should) use the orderchecker under a different user then apache. You could make the checker readonly and executable to only that user. This way your information will be more secure (sftp login, passwords, etc). PHP usually runs under user nobody or apache. These users usually have very limited privileges and probably aren't allowed to use programs like sftp.
Check http://www.php.net/manual/en/features.commandline.php for information on how to run a php script from the command line.
Check http://www.php.net/manual/en/ref.exec.php on how to execute system commands from PHP.
Check http://linux.about.com/od/commands/l/blcmdl1_sftp.htm on how to use sftp from the linux command line.
Check http://www.adminschoice.com/docs/crontab.htm on how to use crontab.
Hope this gives you a couple of ideas on where to start.
Greets,
Marvin