The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
Outputting info on thank you page - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17) +--- Thread: Outputting info on thank you page (/showthread.php?tid=212) |
Outputting info on thank you page - rubycat - Jul 12th, 2009 I'm sure I must be missing it in the documentation but how exactly does one output the information provided by the person who is filling out the form on the "thank you" page when using the API? RE: Outputting info on thank you page - Ben - Jul 12th, 2009 Heya, Sure, this is no problem! On the final page, you should have something like this at the top of your page: PHP Code: <?php To access any of the form field values, you can extract them from the $fields variable. For example, if your form contained "first_name" and "email" fields, you could just add this PHP to your page: Code: First Name: <?=$fields["first_name"]?><br /> Hope this helps - Ben RE: Outputting info on thank you page - rubycat - Jul 12th, 2009 Code: First Name: <?=$fields["first_name"]?><br /> Okay, I was doing it with an "@" sign preceding the $fields but if I remove it, it fails completely. I'm doing it like this: Code: <?=@$fields["first_name"]?><br /> And how do I get the anwsers from a multi-select? If I do this: Code: <?=@$fields["categories[]"]?> If I do it without the brackets, I get the word "Array" output and nothing else. And, if a field is left blank during the data entry, is there a way to conditionally make it so that nothing gets output on the thank you page? RE: Outputting info on thank you page - Ben - Jul 12th, 2009 Good questions! (btw, the @ symbol just prevents any warnings from being outputted to the screen if the variable isn't defined). Displaying the values in multi-select works like this. First, drop the [] characters. It's weird, I know, but they're only used when submitting the data via a form - it tells the server to expect an array of values. Try this instead: PHP Code: <?=join(", ", $fields["categories"])?> It displays the values in $categories, separates by ", ". Quote:And, if a field is left blank during the data entry, is there a way to conditionally make it so that nothing gets output on the thank you page? Sure, here's an example. Code: <?php if (!empty($fields["first_name"])) { ?> All the best - Ben RE: Outputting info on thank you page - rubycat - Jul 13th, 2009 Thank you for this! Works great! |