PHP Form Submission Redirect?

software development

#1

Hey all! I need to get some quick help from “da pros” out there - should be painless for more experienced php-prgrammers…

I have a form that I’ve created in PHP for a non-profit that currently WORKS (yay!) by sending supplied information to the emails we have selected w/ the information provided just fine – heck, I even got hidden formdata to submit… BUT, I need to have a custom “Thank You” page that has one of four different messages, depending on what is selected as payment for donation on the form page (using radio buttons).

Does that make sense?? IOW: once a user “Submits” the formdata, they are redirected to a page that has “hidden” information for all four payment options, EXCEPT for the one they selected.

I’m thinking a good “if, elseif” string, but I’m not experienced enough to figure this out the rest of the way on my own…

Halp!
Charlie


#2

It seems to me that the switch statement would be a “cleaner” (and arguably easier) way to go.

The examples provided on the page I linked above (and the comments added by users) could basically be used “as is”, just replacing the actions indicated in the examples with the redirect info. :slight_smile:

–rlparker


#3

OK – great, sorta…

So, I put the switch statement in the “thanks.php” page? If so, how do I tell it what to show? Or, would it just be easier to have four different “thanks” pages instead?

Actually, I guess the latter is easier, as it won’t require any Javascript, huh?


#4

Actually either way would work: put the switch statement in the form and direct to any one of the four “thank you” pages as appropriate based on the value of the radio button or just redirect to the “thank you” page passing the radio button value as a variable and then use the switch statement to decide what text to display depending upon the value that was passed.

It’s really a matter of choice, and I’m not sure that one is any better than the other, though if you do it by switching to one of four pages, you won’t have to pass a variable :wink: .

Does that make more sense?

Edit: I don’t see that you need to use any javascript in either case.

–rlparker


#5

You rock… thx!

CM


#6

So, and I’m asking cuz I’m new to PHP & the switch conditional, my script would look like this(?):

switch ($response) {
case “PayPal Monthly”:
$_POST = “thanks1.php”;
break;
case “Personal Check”:
$_POST = “thanks2.php”;
break;
}

Not sure if my syntax is even close, so LMK. Obviously, I kept the example simple for the sake of the post-space. I could’ve kept adding cases as needed, I’m sure… LMK if I’m completely off on this! I’m probably pretty close (to being completely off, that is…)

Best!!
Charlie


#7

I’m a little confused looking at your code snippet, though maybe that’s just because I’m seeing it out of context.

Why are you re-assigning a value to $_POST? It would seem to me that you would only want to do this if you were planning to pass that value to the next page, but do you really need to?

If your switch logic determines which page to go to based on the value of $response, isn’t all your processing done at that point, leaving only to display the appropriate page as the “action” taken in each case? As the “thanksx” page is customized for each response, why pass the variable?

I’m sorry if I’m being dense here. :wink:

–rlparker


#8

No, you’re not the dense one – I just don’t know that I’m doing… :wink:

So, how would I code that? I just assumed the $_POST variable, but I’m clueless…

Charlie


#9

Charlie,

Why don’t you just post the code for your working form (with dummy domain name/email addresses), so we can see what your doing. It’ really hard to “guess” what to code without seeing your whole form…

–rlparker


#10

Thanks for your help & patience… Here’s the code:

First Name*
Last Name*
Address 1*
Address 2
City*
State/Province*
Zip/Postal Code*
Country*
Email*
Philip Hayden Foundation assures you that the identity

of all who contact us through this website is kept

confidential: we do not rent, sell, or exchange
our mailing lists.

Phone

Type the text from this image: Captcha Image: you will need to recognize the text in it. (required; case-sensitive)

Select Your Payment Method: 4 easy ways to make payments!* Use PayPal to setup automatic monthly support.

Using your credit card on the Network for Good secure server to sponsor a child is guaranteed safe and secure.

Monthly automatic electronic transfers - CheckFree!

Donate By Check: Please mail a check to: Philip Hayden Foundation 40335 Winchester Rd #E-115 Temecula, CA 92591 USA

PayPal is the authorized payment processor for Philip Hayden Foundation.


#11

Actually, looking at the code you posted changes the process I would suggest you use considerably.

First of all, the data the form collects is passed to a fairly sophisticated commercial formmailer script, which has it’s own way of handling the data and fields. My advice was “generic”, and more applicable to a situation where you were coding your own formmail application.

I took a quick look at the documentation for formprocessorpro on their website, it looks as though that program offers you the functionality you need, as it can handle multipart forms, and is highly configurable. For example, this excerpt:

[quote]browser_outNo
Specifies next page in the sequence to which you are taken after pressing Submit button on the web form, where No – page order. Leave No blank for the first result page

Example:
_browser_out = form-preview.html #defines first result page in multi-page sequence,
_browser_out1=form-next.html #next page for form-preview.html,
_browser_out2=form-thanks.html #next page for form-next.html

_redirect
Specifies page to which you are redirected after pressing Submit button on the web form. Does not process any data, used for redirect purposes only. If you want to output submitted fields, you should use _browser_out instead.[/quote]
…shows a couple of different ways you could approach this. I think coding your own conditional “switch” statement is probably the “hard” way to do this, and fails to use the power and “features” of the script you purchased. While learning this script’s usage might seem difficult, I think that is where you have to start; jumping in and trying to modify it’s functionality without thoroughly understanding it is pretty much guaranteed to be a formula for “grief”.

If you tackle this problem the way you are envisioning it, you will need to build the form in a PHP page and use PHP, with the switch statement, to manipulate the values in the _redirect variable expected by the formprocessorpro script,or use PHP in the _redirect page to selectively display text (as we already discussed) rather than using the a raw HTML form, and using the features of the formprocessorpro script to accomplish your goal.

I suggest you contact support at formprocessorpro’s website and ask them the best way to accomplish this using their script. Consider you will likely have better success with this if you do not presume how you might accomplish your goal, but rather let them suggest to you how you should do it. :wink: It doesn’t make sense to “reverse-engineer” the script to implement a workaround that may not be necessary, and as a paying customer you are entitled to their support. They also advertise “customization services”, though I think the type of information you will need to make this script do what you need will entail less customization than instruction.

I can guarantee you that they know that script a lot better than can I “grok” it with a quick look, and their advice is, consequently, likely to be of much higher quality than mine. I would hate to “kludge” together something “quick and dirty” to"hack" your form (I think giving “bad” or “inappropriate” advice or help is worse than giving none at all!), when the program probably has the functionality you need (once you fully understand it’s workings). Unfortunately, I don’t have the time right now to dig deeply enough into that formprocessingpro program to give you “better” advice. :frowning: Maybe someone else here can do a better job with that than I can right now. :wink:

Please understand that I am not “blowing you off” on this; I just really think that is the way you should go. Of course, if that doesn’t work for you, post back and I’ll try to find some time to look at it further, but I have no guarantee when that might be.

–rlparker


#12

You have been a HUGE help, so I would’ve never taken to the thought that you were “blowing me off” – thanks much! I’ll let you know what comes of it all!!!

Best!
Charlie