Redirection vers une autre page php

Nina -  
adelned Messages postés 3 Statut Membre -
Bonjour,
Voici mon idée ,j'ai une page avec un formulaire :
un champ text matricule ,
un champ select avec deux options soit vol soit train ,
un bouton submit .

je veux quand je clique sur submit je me redirige vers une autre page qui m'offre la possibilité de choisir vol.php ou train.php selon la valeur du select .

voici mon code que j'ai essayé mais il ne marche pas :

<form  class="form1" name="formulaire"   action ="traitement.php" >

<td width="117" height="42">matricule </td>
 <input name="id" id="id" type="text"  size="25 "/>
<select name="tra"  id="tra" >  
<option > Transport</option> 
<option value="vol">vol</option> 
<option value="train"> Train</option> 
</select>
<input type="image" name="imageField" src="images/rechercher.gif"  /></td>

voici ma page traitement.php
<?php 
$tra="";
$tra=$_POST['tra'];
 
if( ($tra=="vol"))

{ header('Location: vol.php');
}
else if ( ($tra=="train"))
{ header('Location: train.php');
}
?>

voici mon erreur :Notice: Undefined index: tra
quelqu'un pour m'aider svp et merci d'avance.

1 réponse

  1. adelned Messages postés 3 Statut Membre 2
     
    salut

    vous oublier methode="post"

    <form class="form1" name="formulaire" action ="traitement.php" method="post">

    <td width="117" height="42">matricule </td>
    <input name="id" id="id" type="text" size="25 "/>
    <select name="tra" id="tra" >
    <option > Transport</option>
    <option value="vol">vol</option>
    <option value="train"> Train</option>
    </select>
    <input type="image" name="imageField" src="images/rechercher.gif" /></td>
    </form>

    vous oublier method="post"
    <?php

    $tra=$_POST['tra'];
    echo " $tra " ;

    if( ($tra=="vol"))

    { header('Location: vol.php');
    }
    else if ( ($tra=="train"))
    { header('Location: train.php');
    }

    ?>
    2