It would be simpler to have a link on your friend's site to a form somehwere on yours, which is processed by your CGI script.
The form handler CGI can be set to redirect to a thank you page back on your friend's site.
So we would have:
Your friend's site page >>
form on your site >>
form processed by CGI script on your site >>
CGI script sends user back to "thank_you.html" page on your friend's site.
If you need to keep it transparent you can put the form into an iFrame on your friend's site, which means the form is handled on yours but people don't see an address change in their browser address bar.
Don't go rolling out iFrames willy nilly though. They have serious accessibility issues, so should be used carefully.
There's a lot of online reference material on iFrames - here's a couple of better than average overviews on them: click here and click here