Lets's look at where things will be located:
(click on the links to see sample scripts)

mysite.com
|
|-reg
| |
| |-key_log.txt
| |-reg_stack.rev
| |-button.html This is no longer necessary
| |-success.html
| |-secrets_file.txt
|
|
|-cgi-bin
| |
| |-myreg1.cgi
| |-myIPN.cgi
| |-myPDT.cgi
| |-myliburl.rev
| |-revolution
|
|-img
etc.

What these files are:

Important: the 'pass-through' variable allows you to track the customer throughout the process. I generate a random number for this in the reg_stack.rev and send it to myreg.cgi
When the button is created, the pass-through variable will be included. So you don't have to include any sensitive info in the [very readable] button script!

Pitfalls Here are some problems I encountered while creating these cgi scripts and PayPal buttons:
1. PDT and IPN use different keys for the pass-through variable! [They're cm and custom]
2. I'm pretty sure your button needs to include this: <input type="hidden" name="rm" value="2"> for the pass-through to, uhm, pass. This was not well documented in PayPal's manuals!

>> next >>
putting it together