I’m making a simple web form for an event invitation.
I have 2 radio buttons. One is a Yes for those attending and the second one a No for those not attending.
How can I make my Thank You Page have a custom message based on each response. For those that will be attending have something like “Looking forward to see you” and for those not attending something like “Sorry you can’t make it”
I usually use Tim’s php forms action when building forms.
You would need to hack the php handler page that Tim’s Action generates in order to do this; or substitute your own form handler instead. You would do something like this:
Actually, I just thought about this a little more, and Tim’s handler
will process the form, but then it will redirect to the Thanks page,
not include the content of it. You’ll need to change the Thanks page
to a php page (just change the extension on the filename from .html
to .php in the Freeway Inspector). Then put <?php print $_GET['message']; ?> in a Markup Item on the Thanks page where you
want it to appear. Finally, in the handler that the Action wrote, look
for a line like this:
header( "Location: ".$successpage );
and change it to look like this:
header( "Location: ".$successpage . '?message=' .
urlencode($message) );
The other method I described would be appropriate for a situation
where you have written your own handler, and it’s all done in one page.
Walter
On Jul 24, 2010, at 9:37 AM, waltd wrote:
You would need to hack the php handler page that Tim’s Action
generates in order to do this; or substitute your own form handler
instead. You would do something like this:
Did you modify the PHP handler page that Tim’s Action wrote to include
the first lump of code I posted? That’s critical to having a value to
bass back to the thanks page from the handler. If you want, copy the
text content of the [your form page]-go.php script generated by Tim’s
Action and paste it here: http://pastie.org Note the URL you get back
from Pastie, and post that here.
Walter
On Jul 24, 2010, at 11:17 AM, Helveticus wrote:
Walt thanks, this seems to work but the success page is blank it’s
not seeing the bit of code placed within the crowbar action
It looks like the Action has overwritten your changes. Try copying the handler file out of your Site folder, then use an FTP application to upload it to your server after you modify it. If this works, then you’ll need to maintain this separate file and upload it each time you publish.
If this works, then you’ll need to maintain this separate file and upload it each time you publish.
Or remove the action once the handler has been created and modified and use Page>Form Setup to set the path to the modified form which you can then upload using either the Upload Stuff or Upload Extra Resources action.
Probably because you don’t have a form element called
‘yourRadioButton’ in your HTML page. What is the Name attribute of the
group of radio buttons? Also, you didn’t add the redirect part back to
the bottom of the script, so your thanks page doesn’t have anything in
the $_GET[‘message’] variable.
Walt thanks for all the help. This is working now - sort of. I get the email responses back to me except it does not matter which radio button get selected the message is always sorry… I do not get the looking forward… when I select the Yes radio button
The radio button names on your form are set to ‘radio’ and the values
are set to ‘YES’ and ‘NO’, so the PHP code for checking the radio
button would then be:
Not sure if this is your problem but if you used the php code as set
before you will always get the ‘Sorry’ message as the value will never
match ‘attending’ since your values are ‘YES’ and ‘NO’.
BTW, I would use something else other than radio as the radio button
names, maybe ‘will_attend’ as in your message:
radio: YES
might not make a lot of sense.
HTH
On Jul 25, 2010, at 9:25 AM, Helveticus wrote:
Walt thanks for all the help. This is working now - sort of. I get
the email responses back to me except it does not matter which radio
button get selected the message is always sorry… I do not get the
looking forward… when I select the Yes radio button
Mike thanks that did the trick. I was looking at the bit in Walters code ==attending and tried to change it to the Title of the radio button with no luck. I never thought of using the Name.
I will change the button names to something more recognizable in the final version.
The $_POST[‘radio’] is the name of the variable while the == ‘YES’ is
referring to the value of that variable, so the above code in English
would read something like:
if the variable called ‘radio’ is set and has the value of ‘YES’ then
we give the variable called ‘message’ the string value of ‘looking
forward…’, if not then we give the variable called ‘message’ the
string value of ‘sorry…’
so the ==‘attending’ refers to the value of the variable called
‘radio’ (in your case), so you could also have changed the value of
‘YES’ to ‘attend’ as long as it matches in the form radio element
value and the code you use to check it, then it will work.
HTH
Glad you got it sorted
On Jul 25, 2010, at 5:13 PM, Helveticus wrote:
Mike thanks that did the trick. I was looking at the bit in Walters
code ==attending and tried to change it to the Title of the radio
button with no luck. I never thought of using the Name.
I will change the button names to something more recognizable in the
final version.