Many Pies

Many Pies

Tuesday, June 11, 2013

NetCommunity donation form based on URL variable

I put some code onto the Blackbus site in response to a question and I was recently asked about it. I realised that my code wasn't on my blog, so I'm putting it here now. What it does is pick something out of the URL for a NetCommunity page and using it, fill in the free text field on a donation form (and choose "other" from the fund dropdown). For instructions on how to get the parsequerystring code installed see my blog entry.

It's designed to use recipient instead of fundid in the URL. It also allows the amount to be set. You'll need to find out the unique id for the "Other" option in your dropdown and put it in the code.

If you want to use a simple form which then redirects to this page then set the post action for your form to be a PHP file which contains this line of code. It assumes you have form fields for pageid (this can be hidden), amount and receipient.

header('Location:' . $_POST['pageid'] . '&amount=' . urlencode($_POST['amount']).'&recipient=' . rawurlencode($_POST['recipient']));

No comments: