Title: redirect code
Last modified: July 25, 2018

---

# redirect code

 *  [jeromeespere](https://wordpress.org/support/users/jeromeespere/)
 * (@jeromeespere)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/redirect-code/)
 * hi
    i want to have a redirection after a test . in my page :
 *     ```
       <form action="" method="post">
          <input type="checkbox" name="prenom[]" value="adriana" />Adriana<br>
          <input type="checkbox" name="prenom[]" value="alessandra" />Alessandra<br>
          <input type="checkbox" name="prenom[]" value="candice" />Candice<br>
          <input type="checkbox" name="prenom[]" value="lili" />Lili<br>
          <input type="submit" value="Envoyer" />
       </form>
   
       [wbcr_php_snippet id="352"]
       ```
   
 * and the code of my snippet
 *     ```
       foreach($_POST['prenom'] as $valeur)
       {
             header('Location: https://www.test.ojjo.ca/inscription/ ');
       }
       ```
   
 * for the test when i submit, i want to change the page. But i come back to the
   same page .
 * do you know what wrong ?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [webcraftic](https://wordpress.org/support/users/webcraftic/)
 * (@webcraftic)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/redirect-code/#post-10534669)
 * Hi,
    Create a snippet with this code, you can modify it for yourself:
 *     ```
       function wbcr_prenom_redirect()
       {
       	if( isset($_POST['prenom']) ) {
       		wp_redirect('https://www.test.ojjo.ca/inscription/');
       		die();
       	}
       }
   
       add_action('template_redirect', 'wbcr_prenom_redirect');
       ```
   
 * This snippet should be run everywhere.
 * Best regards, Alex
    -  This reply was modified 7 years, 10 months ago by [webcraftic](https://wordpress.org/support/users/webcraftic/).
 *  Thread Starter [jeromeespere](https://wordpress.org/support/users/jeromeespere/)
 * (@jeromeespere)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/redirect-code/#post-10544656)
 * hi
    thank you very much but i have now a select option
 *     ```
       <form action="" method="post">
   
       "Inscription poussin né en 2014"<select name=poussin[]> 
       <option selected> 0 
       <option> 1 
       </select> 
   
       "Inscription enfant né en 2015 et +"<select name=enfants[]> 
       <option selected> 0 
       <option> 1 
       <option >2
       </select> 
          <input type="submit" value="Valider" />
       </form>
       ```
   
 * and i want to have a redirection with 2 conditions.
    code of my snippet
 *     ```
       if(($_POST['poussin'] == "1") and ($_POST['enfants'] == "0")){
   
         header('Location: https://www.inscriptionsoccervg.ojjo.ca/inscription-un-poussin/');
       }
       ```
   
 * But it doesn’t work !!
    could you help me please
 * thanks
 *  Thread Starter [jeromeespere](https://wordpress.org/support/users/jeromeespere/)
 * (@jeromeespere)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/redirect-code/#post-10549469)
 * ok thank you it works

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘redirect code’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [jeromeespere](https://wordpress.org/support/users/jeromeespere/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/redirect-code/#post-10549469)
 * Status: not resolved