Join Now

Click here to join our
growing community:

JOIN LOGIN



Docs

Welcome Tour
Handbook
      Markups
      Variables
      Conditions
      Functions
      Forms
      Commands
      Concepts
Extensions
Pro Modules
Developers



Copyright © 2020
Terms of Use
Privacy Policy
BoltWire

Handbook

Passdata

The passdata command is a nifty tool to transfer information from one page to another. They can be sent as a $_GET, $_POST, or $_COOKIE variable and then retrieved on the next page after the form submission.

Here's a simple example to illustrate how this works:

[form]
Name: [text name][submit]
[command passdata name]
[form]

{?name}

This form asks the user to enter a name then passes the name field as a get variable back to the page after the form is submitted. The get variable picks it up and displays whatever value is entered. Here's a slightly more complicated example:

[form]
Name: [text name][submit]
Color: [radio color red] Red   [radio color blue] Blue
[command passdata name,color]
[form]

[if set {?color}]<color={?color}>{?name}</color>[if]

This form illustrates how you can pass data from more than one field at a time. It also shows how you can use the data that is submitted to modify the page display.

Get VS Post

By default, the passdata command uses $_GET to pass its data on. That is, if you entered the name Bob and chose Blue in the form above, you would see the URL of the browser change when you submit the form. It would look something like this:

www.boltwire.com/index.php?p=docs.handbook.commands.passdata&name=Bob&color=blue

In other words, the value is passed to the next page right in the URL. I could directly modify the URL to options that are not even in my form like setting the color to green, and the page would take in the value.

Post values are sent to the next page in a way that is not immediately visible or editable to the user. To do this, in the form above, simply add mode=post to the passdata command.

[command passdata name,color mode=post]

It will work exactly the same, except the URL will not change in any way.

Post values are especially helpful if you need to pass a large amount of data from one page to the other. Consider the following form:

[form]
Directory: [radio dir docs] Docs   [radio dir solutions] Solutions   [radio dir test] Test
[submit]
[command search group={=dir}* template=toc count=false]
[command passdata search mode=post]
[form]

{?search}

This allows the user to choose a section of the site. Upon form submission, BoltWire generates a list of multiple pages in the directory and generates a fully template report. I could send it via GET, but the URL would be extremely long. And if it is too long (more than 2000 characters) my browser is likely to choke on the URL.

By sending it as a POST value, the URL stays short, and I don't have to worry about size limitations.

Of course I could do the form this way to simplify the process and use either GET or POST (though users could change the GET value easily):

[form]
Directory: [radio dir docs] Docs   [radio dir solutions] Solutions   [radio dir test] Test
[submit]
[command passdata dir]
[form]

[(command search group={?dir}* template=toc count=false)]

Cookies

You can also use passdata to store a value on the users computer as a cookie. This requires you to specify how many seconds you want that information to be stored and looks like this:

[form]
Color: [radio color red] Red   [radio color blue] Blue
[submit]
[command passdata color mode=cookie expires=604800]
[form]

{?color}

This asks the user to choose a color and submit the form. BoltWire then stores the color as a cookie for 1 week (604800 seconds). If they leave the site and come back it will remember their color until the time expires. This method is not fool proof as users can clear or block cookies, but it persists longer than GET or POST.

Note: The {?var} markup gives a priority first to post values, then cookie values, and then get values. So you cannot overwrite a post value by adding your own get variable to the URL.