close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Different Page Redirect following insert based on form data

Thread began 1/31/2010 11:32 am by Daryl | Last modified 3/19/2010 2:04 pm by Eric Mittman | 4001 views | 21 replies |

DarylBeta Tester

Different Page Redirect following insert based on form data

Is there a way to have more than one page redirect following a successful insert of data?

I would like to direct a user to a thank you page if they have selected yes from any of the dropdowns on a page, or sent to the next form if all selections were no.

Any ideas?

Sign in to reply to this post

Eric Mittman

One way you could do this would be to use the set session value server behavior. You can set the value of the session variable initially to be the regular redirect page, like to the next page in the form.

You would then have another set session server behavior that is triggered on the posted element being yes. You would set this variable to the thank you page.

Then in the code for the insert where the redirect page is specified you can put in your session variable that holds the redirect page.

This will result in the user going to the next page in the form if they selected all the values from the form, or to the thank you page if they selected yes to the one element.

Sign in to reply to this post

DarylBeta Tester

Sounds perfect......

I have a form with 6 select lists each with a label of Yes and No. The value for Yes is 1 and No is 2.

I have found the "set session value" in the Cookies Toolkit server behaviours. Is this what you mean?

The first part of your solution says to "set the value of the session variable initially to be the regular redirect page". I assume that I go to the Cookie Toolkit set session behaviour;

Trigger - Submit Button
Session Name - Type in a session name of my choice...
Value - next_page.php

Is this right?

The next part of your solution says to "You would then have another set session server behavior that is triggered on the posted element being yes. You would set this variable to the thank you page". I assume that I go to the Cookie Toolkit set session behaviour;

Trigger - Submit Button
Session Name - What would I put here?
Value - Would I select the dynamic value of the select menu? Do I need to set the session value to 1 for each select menu?

The last part says "Then in the code for the insert where the redirect page is specified you can put in your session variable that holds the redirect page"

What would I have to manualy type into the "After update go to" field as there is no lightning bolt here.

Thanks in advance.

Sign in to reply to this post

Eric Mittman

You are very close in your summary of the steps needed, you have got it right for the first set session value server behavior. For the second session variable you will need to have it setup like this:

Trigger - use the lightning bolt to select the first yes/no select list
Session Name - name it the same as the first one you set
Value - for this you would set it to be the thank_you.php page

Once you do this you have two choices for how to proceed, you can either update the trigger for this second set session value to check for the value of the select list being 1 (yes) and then add in more set session value server behaviors, one for each select list, or you could update the trigger for this second set session value server behavior to check if any of the six select lists are set to 1. Here is what these may look like:

method 1: add a set session value server behavior for each of the select lists
custom code for trigger:

php:
if(isset($_POST['your first select list']) && $_POST['your first select list'] == 1){




method 2: have one set session value server behavior for all of the select lists

php:
if((isset($_POST['your first select list']) && $_POST['your first select list'] == 1) || (isset($_POST['your second select list']) && $_POST['your second select list'] == 1) || (isset($_POST['your third select list']) && $_POST['your third select list'] == 1) || (isset($_POST['your fourth select list']) && $_POST['your fourth select list'] == 1) || (isset($_POST['your fifth select list']) && $_POST['your fifth select list'] == 1) || (isset($_POST['your sixth select list']) && $_POST['your sixth select list'] == 1)){



If you have your custom trigger setup like this second example you would only need a total of two set session value server behaviors. If you wanted to go with the first example you would have a total of seven set session value server behaviors. One for the default, then six more for the select lists.

In the code where you are setting the redirect page you would replace the page name with your session variable:

$_SESSION['your session var']

Sign in to reply to this post

DarylBeta Tester

Eric

I have been trying to do this with grouped radio buttons.

If a user selects Yes (1) the redirect works, but if the select no (0) nothing happens.

Equally, I need it to redirect if any of the options is Yes even if it is only one of them.

Any ideas?

Attached Files
application_5.zip
Sign in to reply to this post

Eric Mittman

Have you tested it to confirm that if you select yes for any of them you are taken to the thank_you2.php page?

If so then you only need to add in the else statement for the redirect page. At the end of your custom set session value code you have this:

php:
$_SESSION["inform"] = "thank_you2.php";

}



You should update this to be like this:

php:
$_SESSION["inform"] = "thank_you2.php";

} else {
$_SESSION["inform"] = "<the other page>.php";
}



This will ensure that if the first page is not set to the redirect it will be set to this page specified in the else.

Sign in to reply to this post

DarylBeta Tester

If I select only 1 Yes and the rest No, nothing happens. I only get redirected if I select all to be Yes.

Even with the above suggestion the issue remains the same

Sign in to reply to this post

Eric Mittman

I did a bit of testing on this and determined that you do not have the proper element names in the if statement. It looks like you are referencing the id instead of the name for most of these. When an element is posted it is posted under the name of the element, not the id. This is the trick to working with radio groups, if you have two radio buttons with the same name they will be in the same group. You need to ensure that they each have a unique id though.

When I update the if statement to work with the names of the elements it seems to work as expected, here is the updated if statement that I found to be working:

php:
if((isset($_POST['House_Keeping_group_Council_Tax']) && $_POST['House_Keeping_group_Council_Tax'] == 1) || (isset($_POST['House_Keeping_group_TV_Licence']) && $_POST['House_Keeping_group_TV_Licence'] == 1) || (isset($_POST['House_Keeping_group_Water_Company']) && $_POST['House_Keeping_group_Water_Company'] == 1) || (isset($_POST['House_Keeping_group_Council_Tax_2']) && $_POST['House_Keeping_group_Council_Tax_2'] == 1) || (isset($_POST['House_Keeping_group_TV_Licence_2']) && $_POST['House_Keeping_group_TV_Licence_2'] == 1) || (isset($_POST['House_Keeping_group_Water_Company_2']) && $_POST['House_Keeping_group_Water_Company_2'] == 1)){



You should make sure to updates yours like this, also make sure that you have the else statement to set the alternative redirect page.

Sign in to reply to this post

DarylBeta Tester

Hi Eric, I really appreciate your support!

I have updated my code as suggested. The two statements now look like this;

php:
<?php
if (!session_id()) session_start();
if(isset(
$_POST["HouseKeeping_submit"]))     {
  
$_SESSION["inform"] = "application_6.php";
}
?>
<?php
if (!session_id()) session_start();
if((isset(
$_POST['House_Keeping_group_Council_Tax']) && $_POST['House_Keeping_group_Council_Tax'] == 1) || (isset($_POST['House_Keeping_group_TV_Licence']) && $_POST['House_Keeping_group_TV_Licence'] == 1) || (isset($_POST['House_Keeping_group_Water_Company']) && $_POST['House_Keeping_group_Water_Company'] == 1) || (isset($_POST['House_Keeping_group_Council_Tax_2']) && $_POST['House_Keeping_group_Council_Tax_2'] == 1) || (isset($_POST['House_Keeping_group_TV_Licence_2']) && $_POST['House_Keeping_group_TV_Licence_2'] == 1) || (isset($_POST['House_Keeping_group_Water_Company_2']) && $_POST['House_Keeping_group_Water_Company_2'] == 1)){  

$_SESSION["inform"] = "thank_you2.php";
} else {
$_SESSION["inform"] = "application6.php";
}  
?>



Unfortunately I am still having the same issue, all radios must be ticked as yes for any type of page redirection to take place.

Sign in to reply to this post

DarylBeta Tester

I wondered if I was having problems due to the if statements being positioned above the update behaviour code, so I put it below the update behaviour.

Unfortunately I am still having the same problem where the page is only being redirected if all radio buttons are ticked as a Yes, however I am now being redirected to application_6.php rather than thank_you2.php....

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...