Index not defined

Résolu
raminata Messages postés 8 Statut Membre -  
raminata Messages postés 8 Statut Membre -

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. jordane45 Messages postés 30427 Date d'inscription   Statut Modérateur Dernière intervention   4 831
     

    Bonjour

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


    0
  2. raminata Messages postés 8 Statut Membre
     

    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>

    0
    1. jordane45 Messages postés 30427 Date d'inscription   Statut Modérateur Dernière intervention   4 831
       
      <?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>
      1
  3. raminata Messages postés 8 Statut Membre
     

    Bonjour Jordan,

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

    Merci pour la structure du code.

    0