Index not defined

Résolu/Fermé
raminata Messages postés 7 Date d'inscription jeudi 8 décembre 2022 Statut Membre Dernière intervention 11 décembre 2022 - 8 déc. 2022 à 06:41
raminata Messages postés 7 Date d'inscription jeudi 8 décembre 2022 Statut Membre Dernière intervention 11 décembre 2022 - 9 déc. 2022 à 13:56

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

jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
8 déc. 2022 à 08:12

Bonjour

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


0
raminata Messages postés 7 Date d'inscription jeudi 8 décembre 2022 Statut Membre Dernière intervention 11 décembre 2022
9 déc. 2022 à 03:32

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
jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
9 déc. 2022 à 11:14
<?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
raminata Messages postés 7 Date d'inscription jeudi 8 décembre 2022 Statut Membre Dernière intervention 11 décembre 2022
9 déc. 2022 à 13:56

Bonjour Jordan,

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

Merci pour la structure du code.

0