Support » Plugin: PHP code snippets (Insert PHP) » 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" />
    [wbcr_php_snippet id="352"]

    and the code of my snippet

    foreach($_POST['prenom'] as $valeur)
          header('Location: ');

    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


    Create a snippet with this code, you can modify it for yourself:

    function wbcr_prenom_redirect()
    	if( isset($_POST['prenom']) ) {
    add_action('template_redirect', 'wbcr_prenom_redirect');

    This snippet should be run everywhere.

    Best regards, Alex

    • This reply was modified 3 months, 2 weeks ago by  webcraftic.

    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 
    "Inscription enfant né en 2015 et +"<select name=enfants[]> 
    <option selected> 0 
    <option> 1 
    <option >2
       <input type="submit" value="Valider" />

    and i want to have a redirection with 2 conditions.
    code of my snippet

    if(($_POST['poussin'] == "1") and ($_POST['enfants'] == "0")){

    But it doesn’t work !!
    could you help me please


    ok thank you it works

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.