Passing variable to WFB

User 10077 Photo


Senior Advisor
1,096 posts

I have a form with a hidden field. The form will be displayed on a php page that draws values from a database. One of those values is an ID for an advertiser. I need to pass the ID to the form and use it as the value in the hidden field.

Using the iframe source, I can pass the value to the form.
<iframe src="pagename.php?v=xyz"></iframe>

Then the php can get the value from the URL.
<?php xyz = $_GET['v']; ?>


The last part is to have the variable inserted as the hidden field value. In WFB, I tried inserting php code as the value:
<?php echo $xyz; ?>
but it renders everything as text. I'm guessing that's because the php file that gets exported reads in the htm file as text.

Any ideas how to pass the value from the page to the form?
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/
User 38401 Photo


Senior Advisor
10,951 posts

Can you elaborate on what the use of this is so I can understand what you're trying to do better please? I'm actually just curious as I haven't dabbled much in databases as of yet and am thinking to work on that a bit soon.

I remember using the hidden fields years ago with the Flash version and it was a great way to identify which website or website page a response was generated from. That was about the only thing I used it for at that time and I haven't used one so far in the new form builder yet, but I would assume it's the same type of thing only better.

Anyways, just curious on what that setup would be for is all :)
User 187934 Photo


Senior Advisor
20,271 posts

To sparse php inside your html page you need to alter your .htaccess file.
Add this line to it.
AddHandler application/x-httpd-php .php .html .htm
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 10077 Photo


Senior Advisor
1,096 posts

Eric, Thanks for that suggestion. I use that method on some other sites, but was trying not to do so here because it produces conflicts with another web app I developed that is running on the server. However, your suggestion prompted me to think of a workaround. .htacess affects just the folder it is in and the folders under it. Therefore, for situations like mine, here's a safe way to use the .htaccess.

WFB has the forms appear in an iframe. Therefore, the form can be located anywhere in the domain. Isolate the form into its own directory in the root folder. No other parts of the site should be located in that folder. Put the .htaccess file in that folder. In the web page code that WFB gives to place the form on the site, change the iframe src to reference the new location for the exported form. That way, the .htaccess mod should affect only the form and should not conflict with the other web app.

I hope that makes sense.
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/
User 10077 Photo


Senior Advisor
1,096 posts

Jo Ann, I have a group of recipients for the form submissions. Each recipient has an ID number. That ID number let's me query the recipient's email address from the database.

Each form submission gets stored in the database as a record. Each record gets sent to just one or a small subset of the recipients, not all of them. Therefore, each record needs the ID of the recipient so that when the records are emailed out later, each one is sent to the correct recipient.

I want to pass the ID of the recipient to the form in a hidden field so it can be stored with the record. By using a function as the hidden field value, I can make sure that the passed ID number is valid and then have it show up as the value for the hidden field.
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/
User 38401 Photo


Senior Advisor
10,951 posts

Thanks for the explanation Brian, that's a pretty clever setup, I really gotta get my old fart butt in gear and learn about databases so I can use them more efficiently. Appreciate the info, thanks! :)
User 187934 Photo


Senior Advisor
20,271 posts

Your other option would be to name your page with a php extension.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 10077 Photo


Senior Advisor
1,096 posts

I prefer to keep the files as close to the exported version as possible so that there are minimal changes if I have to update and re-export. With that in mind, here was what ended up working for me.

I added the .htaccess file in the folder where the form files reside.

I used an html field at the very top of the form. I put in a single php include for a page that contained all the code and functions needed.

I added a hidden field for the dynamic value. The value was php.
<?php echo $value; ?>
I exported.

During export, WFB changes the php code in the hidden input. It changes the brackets to their corresponding ascii codes. In the exported html file that contains the form, I had to change the brackets back to > and <.

I uploaded everything and it runs.
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/
User 2820706 Photo


Registered User
3 posts

Good morning. I have WFB version 2.5 Build 5437 and have the same need to pass values to the form and I've done everything I know to but I cannot get the values to the form. I view iframe source and I can see the PHP code that I'm using so that tells me that the form is like ignoring it altogether. Any ideas?
User 187934 Photo


Senior Advisor
20,271 posts

Make sure your server is setup to parse php inside html.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.