Forums Get help. Give help.
I need to use ajax to send a php mailer form. HELP?
-
Hello, I am in a bit of a pickle that I need help on. Basically my problem is this. I have a basic php form that is simple, the results(action) of the form get passed on to plug n pay so that the customer can check out.
However I want to also send an email to myself to get the data so that I can thank the customer and send him/her a receipt right away of their donation. So I am figuring I have to use ajax to do this as you can only have one action in a php form.
Does anyone have any idea how to do this? I have been googling but I havn't found a simple solution that makes sense.
I wasn't sure if I should put this in the php problems or the javascript jungle, so I hope this is the right place.
-97s -
You could also add a php page in between that sends the mail and posts the form.
The problem with both that method and the Ajax idea is that both methods will send you a mail irrelevantly of whether the donation part actually succeeded. Is there no way for the donation process to return on success? -
Ah, this is a good question and one I tried to combat on an online ordering system I did.
The solution I ended up using (probably not the best but I was being rushed) was what @bungle suggested. The client submits the order form, it sends an email to me saying that an order has been submitted and will require payment before processing, then the 'success' page has a hidden form that auto-submits and redirects the user to Paypal where they pay.
Problems with this solution include
1) Not having JS enabled so the payment form doesnt submit to Paypal
2) Closing the browser before paying
3) Browser crashing before paying
In points 2 and 3 you'll end up with unpaid orders in your DB. Not usually a massive problem, you can filter these out.
The better and more correct solution for this is to have a payment notification page on your site. Paypal calls this system IPN (Instant Payment Notification), other systems will have other names.
This option basically sits in the background and, once the payment has been made, the IPN sends a message back to a page your server informing it that a payment has been received. You can then use this data to send an email to yourself
-
Thanks for the ideas. I think I will go with the intermediate page. That will solve my problem. Even though as you both state, it does have errors. In my situation I am manually keeping record of donations in order to send out a thank you card by hand. So I will get the form with their information, then if I don't get the confirmation from my payment processor within the day, I will just know that I lost them in the process some where.
Thanks for the help. Now I just gotta nail down the code.
So php page with a form whose action is a mailer.php page.
Then the mailer.php page sends me a copy, and forwards this information to the payment processor.
Any tips on how to do this, cause ive never done this before? Ill try a search around google.
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Categories
- All Discussions15,493
- CSS Combat7,193
- Other Discussions3,820
- JavaScript Jungle2,455
- PHP Problems2,025
Tips
Just some helpful hints to get the most out of the forums.
