PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Correct Conditional Statement - Probably Simple Answer

  1. studio57designs
    Member

    Hello,

    I have a form that has a dropdown selector. That is what I'm keying on to determine how a redirect will work.

    I'm passing a value through the query string on submit.

    I know its passing the query string, because the links look like:
    http://www.XXXXX.com/?s1=Sentry+Mine+Tracking+System
    or
    http://www.XXXXX.com?s1=Rio+Guest+Tracking+System

    But the logic that I got from the forums isn't working and I'm sure its probably just my lack of knowledge about how to write the statement, so the correct page loads

    <?php
    /*
    Template Name: Form Redirect
    */
    
    $s1 = $_GET['s1'] ; // where s1 is what you passed in the query string
    
    if ($s1 == 'Sentry+Mine+Tracking+System')
      wp_redirect('http://www.XXXXX.com/technology/sentry');
    else
      wp_redirect('http://www.XXXXX.com/rio');
    
    ?>

    The second url is the one that is always directed to regardless of the URL/query string.

    Thanks,
    Louise

    Posted 7 years ago on Tuesday December 11, 2012 | Permalink
  2. studio57designs
    Member

    Ok, well I answered my own question. I needed to use the value of the dropdown, rather than the label and now its redirecting as I'd hoped.

    You can close this for me please.

    Louise

    Posted 7 years ago on Tuesday December 11, 2012 | Permalink
  3. David Peralty
    Administrator

    Glad you figured it out. :)

    Posted 7 years ago on Tuesday December 11, 2012 | Permalink

This topic has been resolved and has been closed to new replies.