Index not defined

Résolu

Bonjour,

J'ai des warning quand j'exécute ce code. Si comme si il ne trouve pas le champ nom_client,, alors que la table client existe et la fonction donne un résultat à l'exécution. Le code devait afficher le bouton rechercher pour chercher un client de la BDD et afficher son  numéro de teléphone mais l'exécution me donne ! ) Notice: Undefined index: NOM_CLIENT le chemin de mon fichier et un autre warning de no data found.

Quelqu'un a une idée? Merci

<?php $telclient =""; $nomclient=""; $reponse="";
//se connecter à la BDD
$conn = oci_connect('mes codes de connection');

//associer la valeur NOM_CLIENT à la variable $nomclient
$nomclient = $_POST['NOM_CLIENT'];

//utiliser la fonction FCT_TELEPHONE


$stid = oci_parse($conn, 'begin :R1 := FCT_TELEPHONE_CLIENT(:P1);end;');
oci_bind_by_name($stid,':R1', $telclient,15);
oci_bind_by_name($stid,':P1',$nomclient);
oci_execute($stid);


//on récupère la réponse
$reponse = "Le numéro de téléphone du client est " . $telclient . "<br>";
oci_free_statement($stid);
oci_close($conn);
?>
<html>
<head>
<title> Mon 3e prog PHP</title>
</head>
<body>
<form method ="post" action ="monfichier.php">
<p> Nom:<input type = "text" name='NOM_CLIENT' value="<?php echo $nomclient;?>"><br> 
<input type ="submit" name="Rechercher" value="Rechercher">
<?php echo $reponse;?>
</form>
</body>
</html>


Windows / Chrome 108.0.0.0

3 réponses

  1. Modérateur

    Bonjour

    http://www.commentcamarche.net/faq/1391-php-notice-undefined-index


    1. Bonjour,

      Merci pour la référence. J'ai essayé comme ça:

      Ce que je remarque est que j'ai un seul warning, Je sai

      sie un nom et clique sur rechercher,  ça fonctionne. Est ce que c'est normal le warning?

      --------------------------------------------------------------------

      <?php $telclient =""; $nomclient=""; $reponse="";
      //se connecter à la BDD
      $conn = oci_connect('mes codes du compte');

      //associer la valeur NOM_CLIENT à la variable $nomclient

      if(isset($_POST['NOM_CLIENT']) ){
          $nomclient = $_POST['NOM_CLIENT'];      
          }

      //utiliser la fonction FCT_TELEPHONE
      $stid = oci_parse($conn, 'begin :R1 := FCT_TELEPHONE_CLIENT(:P1);end;');
      oci_bind_by_name($stid,':R1', $telclient,15);
      oci_bind_by_name($stid,':P1',$nomclient);
      oci_execute($stid);
      //on récupère la réponse
      $reponse = "Le numéro de téléphone du client est " . $telclient . "<br>";
      oci_free_statement($stid);
      oci_close($conn);
      ?>
      <html>
      <head>
      <title> Mon 3e prog PHP</title>
      </head>
      <body>
      <form method ="post" action ="mon fichier.php">
      <p> Nom:<input type = "text" name='NOM_CLIENT' value="<?php echo $nomclient;?>"><br> 
      <input type ="submit" name="Rechercher" value="Rechercher">
      <?php echo $reponse;?>
      </form>
      </body>
      </html>

      1. Modérateur
        <?php 
        
        //se connecter à la BDD
        $conn = oci_connect('mes codes du compte');
        
        //associer la valeur NOM_CLIENT à la variable $nomclient
        $telclient =""; 
        $nomclient=""; 
        $reponse="";
        if(isset($_POST['NOM_CLIENT']) ){
          $nomclient = $_POST['NOM_CLIENT'];      
           
          //utiliser la fonction FCT_TELEPHONE
          $stid = oci_parse($conn, 'begin :R1 := FCT_TELEPHONE_CLIENT(:P1);end;');
          oci_bind_by_name($stid,':R1', $telclient,15);
          oci_bind_by_name($stid,':P1',$nomclient);
          oci_execute($stid);
          //on récupère la réponse
          $reponse = "Le numéro de téléphone du client est " . $telclient . "<br>";
          oci_free_statement($stid);
          oci_close($conn);
        }
        ?>
        <html>
          <head>
            <title> Mon 3e prog PHP</title>
          </head>
          <body>
            <form method ="post" action ="mon fichier.php">
              <p> Nom:<input type = "text" name='NOM_CLIENT' value="<?php echo $nomclient;?>"><br> 
              <input type ="submit" name="Rechercher" value="Rechercher">
              <?php echo $reponse;?>
            </form>
          </body>
        </html>
    2. Bonjour Jordan,

      C'est mon accolade qui n'était pas à la bonne place.

      Merci pour la structure du code.