Function That Allows Page Self-Post and Then Redirect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
octopusgrabbus
Forum Newbie
Posts: 7
Joined: Tue Jan 13, 2009 1:10 pm

Function That Allows Page Self-Post and Then Redirect

Post by octopusgrabbus »

Other than nice graphics, I have a very simple web page for food donations for our town. (There will also be one for fuel assistance.) A user enters a donation amount, clicks on Next, and is redirected to a payment processor's site. I even have sample code, but there's a catch.

Before Next's onClick causes the form's action to go to a new URL (of the payment processor), the form must first post to itself. It must post to itself, so that the donated amount is read, combined with more information required by the payment processor, like username and password, and is then encrypted.

If the user enters the amount and clicks on Next, the form does get a chance to self-post, and the hand-off to the payment processor fails. If I put a contrivance into the web page, like a Check Amount button, then asking the user to click on that causes the form to post to itself. Then, when the user presses Next, the hand-off to the payment processor works fine.

I would prefer not to have a contrivance. How can I get a form to post to itself (when Next is pressed) and then hand-off to a new URL?

Thanks.
cmn
atonalpanic
Forum Commoner
Posts: 29
Joined: Mon Mar 02, 2009 10:20 pm

Re: Function That Allows Page Self-Post and Then Redirect

Post by atonalpanic »

You could use AJAX, or set the action to the same page and on that page check ISSET($_POST['submit'])
octopusgrabbus
Forum Newbie
Posts: 7
Joined: Tue Jan 13, 2009 1:10 pm

Re: Function That Allows Page Self-Post and Then Redirect

Post by octopusgrabbus »

I will give this a shot. Thanks.
Post Reply