RackForms v7.8.8
www redirect
Site Tag Line
Latest Release: Build 958 - Arpil 18th, 2023
Contact Us  Purchase Options Purchase Options Contact Us
header-image


 
Top Link
Text WWW Redirect

In Brief: Redirect a user to another web page or location.

Dependencies: A confirmation page.

Hints & Tricks: Full Page Redirect Hint: In many cases you'll want to use a redirect with a form that is included in a parent page via the iFrame include method. You will notice however, that by default, a redirect will only populate the iFrame with the redirected pages' content, not the entire window. To get your redirect content to populate the parent window (the whole window, not just the iFrame area), add a simple delay value to the Delay Before Redirection (seconds) field. This will force RackForms to use a JavaScript redirect which has the effect of making the redirect code effect the whole page, not just the iFrame.

Options/Properties

Basic Attributes

Design Notes
These are notes you can input that help you and other production staff understand your confirmation elements logic and purpose. This text is never used in the live form in any way, it is only for internal development.

Confirmation/Query Condition

Confirmation Condition PHP Code

This field allows you to specify a condition which must be met for the confirmation field to be processed.

We can create code manually, or use the Condition Wizard.

Condition Wizard

If you're new to using conditions, or simply want to have RackForms generate the condition code for you, the wizard is a fast and easy way to do so. To create a confirmation condition, simply follow the wizard from top to bottom.

Start by mousing over the This Field: select item. All fields in your form will display, select the item you want to base the condition on.

Please note if we select a Checkbox field an additional select item will display, Having This Checkbox Value (optional):. This select item will display all possible values for that checkbox. Select which value you want to base the condition on. When you do, the condition process is complete.

For all other fields, the next step is to set the Must: field. This will take the value of Equal or Not Equal, and several others.

Finally, type into the This Value: box to set which value the form field we selected above will validate against.

If you want to add additional conditions, such as a name must be Equal to Steve and age less than 10, first select the Additional Condition button and start from the top of the wizard again.

Hand Coding Conditional Code

The logic takes the form of:

Variable 1 | Condition | Variable 2

For example, let's assume we have a radio item in our form with the Name/Value of opt_1. The radio item has two possible vales, 'Yes' and 'No'. If the value of opt_1 is 'Yes' we want to send an email, if no, we do not.

We would write the Confirmation Condition PHP Code as such:

#{opt_1} == 'Yes'

In other words, we use the token for our field variable like we would in other property boxes, that is, a pound sign (#) followed by the Name/Value of the field in braces. Recall that at run time this token evaluates to the value set by our forms users, which in this case will be the value of the radio button with the Name/Value of opt_1.

We then set the comparison, in this case out comparison is equal too, denoted with the double == sign. Finally, because we know our radio item is a string value that can be 'Yes' or 'No', we wrap the value we want to check for in single tick marks.

On the raw code side, RackForms wraps the token call in an isset() block, which is further wrapped in the proper PHP if() syntax:

if(isset($_SESSION['qs']["{$_SESSION['entry_key']}"]['opt_1']) && $_SESSION['qs']["{$_SESSION['entry_key']}"]['opt_1'] == 'Yes') { // condition code start

When run, if the users set value for the radio box was 'Yes', we would process this confirmation element.

Using Array Based Form Elements (Checkboxes)
PHP Treats checkbox items a little differently than other elements. The good news is the only element that needs this special attention is a checkbox field. The difference then, is that in order to use checkbox items we need to place an index indicator just after the form field name.

For example, lets say we have a checkbox field with the Name/Value: email_condition, and it has two elements: Recipient A and Recipient B

To process this field in our condition statement we append the proper index in the format of [index-number]. It's quite simple when you see it in practice:

#{email_condition[0]} == 'Recipient A'

#{email_condition[1]} == 'Recipient B'

Please note the [0] and [1]. These are the index positions of the field being checked. Compare this to a standard field token:

#{email_condition} == 'Recipient A'

A checkbox group has several items, the [0] and [1] bit tell RackForms which number item to grab.

How do we know which number to use? In our example the checkbox field has two values, and array indexs start with 0. Thus, the first field, Recipient A, is [0], and Recipient B is [1].

The rule then is our numbering simply adds 1 for every checkbox item in the group, and always starts at 0.

WWW Redirect

Redirect Address (Fully qualified)

This is the address of the page you would like to redirect to.

A page redirect is the last element to be processed on the confirmation page, so if you have any other processing elements, they will work as expected.

Note: All redirects will open the link in the same window as it's called in unless you specify a redirect delay (please see below).

Redirect Address Dynamic Variable Support
The Redirect Address field supports PHP variables; the way you'll include these variables depends on whether you use the Delay Before Redirection setting or not.

Case 1: You do not have a value in the Delay Before Redirection box:
Include PHP variables using a wrapping brace as in:

{$php_var}

Case 2: You are using a value in the Delay Before Redirection box:
Use a full PHP echo statement as in:

<?php echo $var; ?>

You can use these dynamic variables to perform logic after your form has been submitted. For example, you may have a form that when submitted you redirect your users to a special offers page. This page is on another server so you cannot transfer the session, but you can transfer information using a query string.

You could also use this feature in a situation where you have an iFrame include form on one page and want to collect more information on another page, this second page being in a totally different format than the first (such as going from small window to a full page form). The problem will arise in that the redirect call will need to replace the first window with the second, full page window. This can only happen if we use the redirect delay, and using the PHP variables we can then transfer the initial form fields data as well.

One final hint: It helps to remember that with the PHP Top Code block we can add any custom code we need to a page. This is important in terms of dynamic variables we use here, as sometimes we'll need to process a value first from say, another form field or _GET variable, then plop that variable into the Redirect Address box.

Delay Before Redirection

This field, if set with a integer value, will delay the Redirect Address from loading for the number of seconds you place in this field. Please be aware, if you place a value in this box it will override any Custom Redirection Code logic, and will instead load the address from the Redirect Address field above. This is done because the custom logic advanced programmers would use could use its own delay code, or would perform more advanced operations this field does not yet support.

Also be aware this redirection call is based on Javascript, and may not be available to all browsers and user configurations. However, the upside of using the JavaScript redirect, as noted in the Hints and Tricks section above, is that your redirect will cause the entire window to load your new content, as opposed to just the iFrame.

For reference, you can use this JavaScript to perform a full page redirect:

<script type="text/javascript">
   function redir() {
	setTimeout("window.open('http://www.rackforms.comyahoo.com', '_top', '', false);", 10);
}
</script>

Delayed Redirect Target

New to Build 671, this feature allows us to set to the window the timed redirect will attempt top replace. By default this is set to _top, which means the form frame will replace the entire window. This is particularly useful in cases when the form is embedded in a larger page via an iFrame, and you want the redirect to replace not just the iFrames contents, but the entire window.

By contrast, sometimes you will not want this, you will only want the iFrames contents to be replaced. If this is the case, you will want to use _self or experiment with the other options.

Custom Redirect Code

As the WWW Redirect module is the last bit of code to run on all confirmation pages, you can provide custom redirect code logic to handle special cases such as a redirect based on user input. For example, you could use this code to redirect to the value of redirect_site, a select field element created on the first page of our form:

// custom redirection 
$site = $_SESSION['qs']["{$_SESSION['entry_key']}"]['redirect_site']; 
switch($site){ 
	case 'Yahoo.com' : 
		header("Location: http://www.rackforms.comyahoo.com"); 
		break; 
	case 'Amazon.com' : 
		header("Location: http://www.rackforms.comamazon.com"); 
		break; 
	default : 
		header("Location: http://www.rackforms.com"); 
} 
exit;

IMPORTANT NOTES: Unlike the PHP Head Code property of all form pages, the Custom Redirect Code you create cannot be enclosed in PHP tags (<?php and ?>), as they are already created for you. Wrapping your code in braces will cause your pages to fail.

It is also important to note that RackForms will attempt to process some clean up routines after a Delayed or Standard Redirect (not using Custom Redirect Code), but will not do so unless told when using Custom Redirect Code. This behavior has an important consequence:

By default all saved $_SESSION data from the users session remains intact after a Custom Redirect Code redirect.

This means a user could be redirected from your form page, hit the back button on their browser, and all their previously filled in form fields will still be set.

This may be desirable in some cases, other not. To keep session data you do nothing, as this is the default behavior. To erase all session data, starting with Build 617 you can issue a call to:

clear_fb_session();

Which is a simple function that clears all RackForms session data. Now when a user hits the back button after the redirect the form fields will be blank.

Dynamic Variables Support

This field now support the inclusion of dynamic variables in the form of:

PHP Variables:
$php_var or PHP{php_var}

Field Variables
#{field_name}

Important Update Note: As of build 630 It is important to note that field variables such as #{text1} and PHP variables such as $var or ${var} will be returned as raw variables, that is, in the form of:

$_SESSION['qs']["{$_SESSION['entry_key']}"]['text1']

Why does this matter? Because the field variable isn't tucked away in braces as was previously the case (pre-Build 630), you can now use field variables to process more complex logic such as switch statements and the like.

For example, we may have a text field with an Name/Value of text1 with a dollar value of 14.50 as the fields entered value. We could use the following code in the Custom Redirect Code area:

if(#{text1} == '14.50'){
echo 'hit';
}

Which would return hit. Thus, the value returned by our token isn't treaded as a simple string.


So many features, So little time