Custom Message in Forms

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.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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:

if (isset($_POST['yourRadioButton']) && 
     $_POST['yourRadioButton' == 'attending'){
    $message = 'looking forward ... ';
}else{
    $message = 'sorry...';
}

And then, in the spot on the page where you want that message to appear, you would place a markup item with

<?php print $message; ?>

And your message will appear.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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:

if (isset($_POST['yourRadioButton']) &&
    $_POST['yourRadioButton' == 'attending'){
   $message = 'looking forward ... ';
}else{
   $message = 'sorry...';
}

And then, in the spot on the page where you want that message to
appear, you would place a markup item with

<?php print $message; ?>

And your message will appear.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Yes I did - Just posted a fresh file to Pastie http://pastie.org/1058389

Just noticed on this version after a fresh republish

header( "Location: ".$successpage );

has changed to

header( "Location: ".$notindomain_errorpage );

freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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.

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I have saved a separate version of the php handler file but I’m not sure where to add this lump of code.

if (isset($_POST['yourRadioButton']) &&
$_POST['yourRadioButton' == 'attending'){$message = 'looking forward … '; }else{ $message = 'sorry…'; }

I get a syntax error now when I submit the form


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This is what I now have in the handler page http://pastie.org/1058647


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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.

Try this:

http://pastie.org/1058818

and look where I commented that you need to change yourRadioButton.

Walter

On Jul 24, 2010, at 4:46 PM, Helveticus wrote:

I have saved a separate version of the php handler file but I’m not
sure where to add this lump of code.

if (isset($_POST[‘yourRadioButton’]) &&
$_POST[‘yourRadioButton’ == ‘attending’){$message = 'looking
forward … '; }else{ $message = ‘sorry…’; }

I get a syntax error now when I submit the form


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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 test page is here http://freshbrand.com/evite


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

it does not matter which radio button get selected the message is always sorry

Yes I am at the same stage at you (same message no matter which button) but I have added a bit to personalise it http://www.deltadesign.co/formtest.html

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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:

if (isset($_POST[‘radio’]) &&  $_POST[‘ radio’ == ‘YES’){$message =  
‘looking forward
  ‘; }else{ $message = ‘sorry
’; }

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

the test page is here http://freshbrand.com/evite


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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.

Once again Walt and Mike thanks for the help.

Cheers, Marcel


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

if (isset($_POST[‘radio’]) &&  $_POST[‘ radio’] == ‘YES’){$message =  
‘looking forward
‘; }else{ $message = ‘sorry
’; }

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.

Once again Walt and Mike thanks for the help.

Cheers, Marcel


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Don’t forget to quote the value you are comparing to:

$foo == 'YES'; //good
$foo == YES; // bad, sure to throw an error

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options