Click here to Skip to main content
15,939,778 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I'm sorry to say for my little church but I am about the best web guy they have, poor church. I'm a little over my head and could sure use some help, anyway to my question.

We have setup with a credit card company to accept donations online. I wrote an html form with several javascript functions just to get everything to format correctly and total the giving to different areas (i.e. tithe, youth , pastor appreciation etc...) before sending it to the credit card company's site.

My problem is the credit card company does not forward these additional fields back to us so that we can see how to distribute the gift.

Is there a way to have the action send the data to their site but also send the form results to an email address?

I gave the long version of this story in case I am totally going about this the wrong way. Any point in the right direction would be appreciated.

Updated 4-May-11 13:33pm

1 solution

If your site is Apache/PHP it's easy (and I'm sure it is just as easy with IIS/ASP.NET, I just don't know the details). When you process the form, you will be accessing a lot of $_GET['xxx'] or $_POST['xxx'] variables. Build these and some literal text into a string, then email it like so:
$body = $_POST['name'] . ' has offered ' . $_POST['amount'] . ' for ' . $_POST['purpose'];
$to = '';
$subject = 'web donations';
$ok = mail($to, $subject, $body);
if (!$ok)
  // complain - it didn't work

You may need to talk to your hosting provider to get the email setup right, but when they do get it right, this will do exactly what you want.
which reminds me, I need to beat up on a hosting company to get email to work on a site I look after. Moved to a new hosting company a month ago, and they still haven't got it right!


[edit] typos
Share this answer
dwayne2700 10-May-11 20:03pm    
Thank you for your quick response. It took me a few days to get back because I was trying to get a good understand of how to implement your solution. I guess I am still stuck.

It e-mails great, but I am not getting the data from the form fields. Will I need to make my original form gather the field data and then have the action point to a php file with your example and then post from that file to the credit card company's site? I have been reading a ton of tutorial site but still can't get the data to the e-mail.
dwayne2700 10-May-11 21:34pm    
Never mind. I figured it out. Thanks a bunch for your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900