Announcement

Collapse
No announcement yet.

SC_REDIR redirect to website URL outside of SC

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • SC_REDIR redirect to website URL outside of SC

    I am trying to redirect after form data has been inserted into a DB using the code below in the onAfterInsert Event.

    // Redirection parameters
    $redir_app = '/activation.php?email='. {email}; // Application name
    $redir_target = '_parent'; // Target window (_blank, _self, _parent or modal)

    // Redirection

    sc_redir($redir_app);

    As you can see I am trying to pass a variable from the form called "email" to the activation.php script to have that variable available for the script for display. When I look at the request variables posted to the activations.php script the "email" value is set to "this->email" instead of the actual email address. The JSON encoded $_GET array is below:

    {"email":"$this->email","nmgp_parms":"","nmgp_url_saida":"\/sc\/form_registrations\/form_registrations.php","script_case_init":"386",
    "script_case_session":"plhot133i0q06pn8cimrhq77f2" }

    Am I able to pass form variables like this to other URLs?

  • #2
    Hello,

    Yes, after all you are just passing a $php variable.

    Maybe on the AfterInsert() {email} no longer has any value.

    You could try two different approaches, store {email} value on a global variable on the ValidateSuccess()

    [email] = {email};

    and then pass [email] on the redirection parameters.

    Or you could try to see what {email} value is on AfterInsert().

    I hope you have understood. Please let me know on any advancements.

    regards,
    Bernhard Bernsmann

    Comment


    • #3
      Thanks for the response but I carefully went back to the documentation and worked through the recommended way to pass variables to the outside php script and it worked. Here is the code I used:

      // Redirection parameters
      $redir_app = '/activation.php'; // Application name
      $redir_target = '_parent'; // Target window (_blank, _self, _parent or modal)
      $redir_param = array( // Param list, add as many as needed
      "email" => "{email}",
      "param_2" => "value_2"
      );
      $redir_param = json_encode($redir_param);
      // Redirection

      sc_redir($redir_app,$redir_param,$redir_target);



      The trick was encoding the $redir_param before sending it and then decoding it inside the other script. I have to use

      $nmgp_parms = json_decode($_POST[nmgp_parms],true);

      to get access the array.

      Comment

      Working...
      X