IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Afficher une requête dans un html formaté


Sujet :

PHP & Base de données

  1. #1
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut Afficher une requête dans un html formaté
    Bonjour à vous

    Je suis un grand débutant en PHP et je suis confronté à un soucis qui me bloque depuis quelques jours déjà, j'ai donc besoin de votre aide.

    J'ai crée ( à l'aide des cours php) un formulaire pour encodé des informations dans une BDD qui fonctionne au poil !

    Maintenant je dois refaire une page html qui reprendre la même structure que mon formulaire d'encodage html mais pour la consultation via un champ de recherche. Et c'est la que je coince !

    Voici la partie HTML :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    <form method="post" action="try.php" class="register">
    <h1>Consultation des Biens</h1>
                <fieldset class="row1"> <legend>Détails du bien </legend>
                    <p> <label style="width: 100px;">Code bien </label>
                        <input name="codebien" type="search" style="width: 100px;" />
     
                        <label style="width: 100px;">Type de Vente</label>
                        <input type="text" name="typevente"style="width: 100px">
     
                        <label style="width: 100px;">Type de Bien </label>
                        <input type="text" name="typebien"style="width: 100px;">
     
                    <p> <label style="width: 100px;">Agence </label>
                        <input type="text"name="agence"style="width: 100px;"/>
     
                        <label style="width: 100px;">Actif </label>
                        <input type="text" name="actif"style="width: 100px;">
     
                        <label style="width: 100px;">Etat </label>
                        <input type="text" name="etat"style="width: 100px;">
                    </p>
                    <p> <label style="width: 100px;">Date F</label>
                        <input name="datef" type="text"style="width: 100px;" id="datef" />
                        <label style="width: 100px;"id="dateimmo">Date I</label>
     
                        <input name="dateimmo" type="text" style="width: 100px;"id="datei" />
                        <label style="width: 100px;" id="dateexpir">Date expiration </label>
     
                        <input name="dateexpir" type="text" style="width: 100px;" id="dateexpira" />
                    </p>
                    <p> Remarques :<textarea class="remarque" name="remarque" row="24" cols="45" style="height: 80px; width: 600px;"></textarea>
                </fieldset>
    Et voici le ode php de traitement. :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    <?php
     
    try {
        $bdd = new PDO('mysql:host=localhost;dbname=agence;charset=utf8', 'ludo', '');
    } catch (Exception $e) {
        die('Erreur : ' . $e->getMessage());
    }
     $codebien = $_POST['codebien'];
    $requete="SELECT
        `Code_Bien`,
        `Agence`,
        `Type_Vente`,
        `Type_Bien`,
        `Date_F`,
        `Date_I`,
        `Date_Expiration`,
        `Actif`,
        `Etat`, 
        `Remarques`
        FROM `biens`
        WHERE 'Code_Bien' ='".$codebien."'";
         $response = $bdd->query($requete);
    Ce code qui est incomplet, je l'ai réalisé à l'aide des cours, hors de 1 il ne fonctionne pas et de plus j'aimerais qu'il sois traité dans ma page html afin que lorsque dans mon champ search je tape "aze" j'ai les informations de ma table lié au bien aze aux bons endroits.

    Et je bloque la.


    Merci à vous de votre aide.

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    On ne met pas directement dans une requête une valeur saisie par l'utilisateur, il faut utiliser une requête préparée :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    $requete="SELECT
        `Code_Bien`,
        `Agence`,
        `Type_Vente`,
        `Type_Bien`,
        `Date_F`,
        `Date_I`,
        `Date_Expiration`,
        `Actif`,
        `Etat`, 
        `Remarques`
        FROM `biens`
        WHERE 'Code_Bien' = :codebien";
    $response = $bdd->prepare($requete);
    $response->execute(array(':codebien'=>$_POST['codebien']));
    $data = $response->fetch(PDO::FETCH_ASSOC);
    Au passage, uniformise tes noms car "codebien" <=> "Code_bien" c'est source d'erreur.

    Pour le formulaire tu dois seulement afficher la valeur. Le code de la requête va juste avant le formulaire, il n'y a pas besoin de 2 fichiers.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <input name="codebien" type="search" value="<?php echo htmlspecialchars($data['Code_bien']); . '" style="width: 100px;" />
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    Merci Sabotage pour ta réponse rapide.

    J'ai donc placé mon code php dans mon reponse3.php en changeant codebien par bien tout simplement.
    Mais du coup tout est parti en sucette.


    [modif] : ligne 17 j'ai changer pour bien
    Nom : tableau.jpg
Affichages : 84
Taille : 67,8 Ko




    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <head>
            <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
            <title>CSS Registration Form</title>
            <link rel="stylesheet" type="text/css" href="css/default.css" />
     
        </head>
        <?php
     
    try {
        $bdd = new PDO('mysql:host=localhost;dbname=agence;charset=utf8', 'ludo', '');
    } catch (Exception $e) {
        die('Erreur : ' . $e->getMessage());
    }
     $codebien = $_POST['codebien'];
    $requete="SELECT 
        `Code_Bien`, 
        `Agence`, 
        `Type_Vente`, 
        `Type_Bien`, 
        `Date_F`, 
        `Date_I`, 
        `Date_Expiration`, 
        `Actif`, 
        `Etat`, 
        `Certif_PEB`, 
        `Photos`, 
        `Plan`, 
        `PDF_Plan`, 
        `Modif_Plan`, 
        `Fichier_Plan`, 
        `Date_Reception`, 
        `Date_Creation`, 
        `Date_Envoie`, 
        `Date_Corrections`, 
        `Date_Publication`, 
        `Remarques` 
        FROM `biens`
        WHERE 'Code_Bien' ='".$bien."'";
     $response = $bdd->query($requete);
    $response = $bdd->prepare($requete);
    $response->execute(array(':bien'=>$_POST['bien']));
    $data = $response->fetch(PDO::FETCH_ASSOC);
     
        ?>
        <body>
     
     
                        <h1>Consultation des Biens </h1>
                <fieldset class="row1"> <legend>Détails du bien </legend>
                    <p> <label style="width: 100px;">Code bien </label> 
                        <input name="bien" type="search" value="<?php echo htmlspecialchars($data['Code_bien']); ?> " style="width: 100px;" />
     
                        <label style="width: 100px;">Type de Vente</label>
                        <input type="text" name="typevente"style="width: 100px">
     
                        <label style="width: 100px;">Type de Bien </label>
                        <input type="text" name="typebien"style="width: 100px;">
     
                    <p> <label style="width: 100px;">Agence </label>
                        <input type="text"name="agence"style="width: 100px;"/>
     
                        <label style="width: 100px;">Actif </label>
                        <input type="text" name="actif"style="width: 100px;">
     
                        <label style="width: 100px;">Etat </label>
                        <input type="text" name="etat"style="width: 100px;">
     
                    </p>
                    <p> <label style="width: 100px;">Date f</label> 
                        <input name="datef" type="text"style="width: 100px;" id="datef" /> 
                        <label style="width: 100px;"id="datei">Date I </label> 
                        <input name="datei" type="text" style="width: 100px;"id="dateim" /> 
                        <label style="width: 100px;" id="dateexpir">Date expiration </label> 
                        <input name="dateexpir" type="text" style="width: 100px;" id="dateexpira" />
                    </p>
                    <p> Remarques :<textarea class="remarque" name="remarque" row="24" cols="45" style="height: 80px; width: 600px;"></textarea>
                </fieldset>
                <fieldset class="row2"> <legend>Plans </legend>
                    <p style="text-align: left;">* 
                        <label>Plan</label> 
                        <input name="plan" type="checkbox" value="oui" /> 
                        <label class="gender">Oui</label> 
                        <input name="plan" type="checkbox" value="non" /> 
                        <label class="gender">Non</label> </p>
     
     
                    <p> <label>Nouveau PDF</label> <input name="newpdf"style="width:100px;" type="text" class="long"  />
                        <label>Date reception</label> <input name="reception"style="width:100px;" type="text" />	</p>
                    <p> <label>Modif PDF </label> <input name="modif"style="width:100px;" type="text" class="long"  />
                        <label>Date creation</label> <input name="creation"style="width:100px;" type="text" />		</p>
                    <p> <label>Fichier plan</label> <input name="fichier"style="width:100px;" type="text" class="long" />
                        <label>Date agence</label> <input name="dateagence"style="width:100px;" type="text" /> </p>
                    <p> <label>Date corrections</label> <input name="correction"style="width:100px;" type="text" />
                        <label>Date publication</label> <input name="publication"style="width:100px;" type="text" /> </p>
     
                </fieldset>
                <fieldset class="row3"> <legend>Autre Informations </legend>
                    <p> <label>Numéro PEB</label> <input name="certifpeb"type="text"  /></p>
                    <p> <label> ID BDD</label> <input name="idbdd"type="text" /></p>
                    <p> <label> Photos </label> <input name="photo"type="text"/></p>
     
     
     
                                </fieldset>
     
                <div><input class="button" type="submit" value="Valider »"/></div>
     
            </form>
     
        </body>
    </html>

    Du coup aucune information n'est affiché quand je valide

  4. #4
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Excuse moi j'ai raté mon collage. J'ai corrigé le code dans mon message précédent.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  5. #5
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    Cela ne fonctionne toujours pas j'ai :
    Notice: Undefined index: bien in C:\wamp\www\reponse.php on line 43

    $response->execute(array(':bien'=>$_POST['bien']));

    et au sujet
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <input name="codebien" type="search" value="<?php echo htmlspecialchars($data['Code_bien']); . '" style="width: 100px;" />
    j'ai mis à la place
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     <input name="bien" type="search" value="<?php echo htmlspecialchars($data['Code_bien']); ?> " style="width: 100px;" />
    Le point me donné une erreur.

  6. #6
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Dans ton formulaire c'est "bien" ou "codebien" ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  7. #7
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    bien dans le formulaire et Code_Bien le nom du champ de ma bdd
    Tout les "codebien" sont changé en "bien"

  8. #8
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Il n'y a plus de <form> dans le code que tu as montré.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  9. #9
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    Voila le code au complet de la page.

    Dans ce que j'arrive à comprendre :

    Ma page php sert à chercher un bien encodé dans ma BDD, puis une fois que je valide cette même page se refresh avec les informations de de mon bien.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <head>
            <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
            <title>CSS Registration Form</title>
            <link rel="stylesheet" type="text/css" href="css/default.css" />
     
     
     
     
        <?php
     
    try {
        $bdd = new PDO('mysql:host=localhost;dbname=fiks;charset=utf8', 'ludo', '');
    } catch (Exception $e) {
        die('Erreur : ' . $e->getMessage());
    }
    //$bien = $_POST['bien'];
    $requete="SELECT 
        `Code_Bien`, 
        `Agence`, 
        `Type_Vente`, 
        `Type_Bien`, 
        `Date_Fiks`, 
        `Date_Immoweb`, 
        `Date_Expiration`, 
        `Actif`, 
        `Etat`, 
        `Certif_PEB`, 
        `Photos`, 
        `Plan`, 
        `PDF_Plan`, 
        `Modif_Plan`, 
        `Fichier_Plan`, 
        `Date_Reception`, 
        `Date_Creation`, 
        `Date_Envoie`, 
        `Date_Corrections`, 
        `Date_Publication`, 
        `Remarques` 
        FROM `biens`
      WHERE 'Code_Bien' = :bien";
    $response = $bdd->prepare($requete);
    $response->execute(array(':bien'=>$_POST['bien']));
    $data = $response->fetch(PDO::FETCH_ASSOC);
     
        ?>
     
     
     
     
     
     
     
     
        </head>
     
        <body>
           <form method="post"  action="reponse3.php" class="register">
     
                        <h1>Consultation des Biens FIKS</h1>
                <fieldset class="row1"> <legend>Détails du bien </legend>
                    <p> <label style="width: 100px;">Code bien </label> 
     
                       <input name="bien" type="search" value="<?php echo htmlspecialchars($data['Code_bien']); ?> " style="width: 100px;" />
                        <label style="width: 100px;">Type de Vente</label>
                        <input type="text" name="typevente"style="width: 100px">
     
                        <label style="width: 100px;">Type de Bien </label>
                        <input type="text" name="typebien"style="width: 100px;">
     
                    <p> <label style="width: 100px;">Agence </label>
                        <input type="text"name="agence"style="width: 100px;"/>
     
                        <label style="width: 100px;">Actif </label>
                        <input type="text" name="actif"style="width: 100px;">
     
                        <label style="width: 100px;">Etat </label>
                        <input type="text" name="etat"style="width: 100px;">
     
                    </p>
                    <p> <label style="width: 100px;">Date fiks</label> 
                        <input name="datefiks" type="text"style="width: 100px;" id="datefiks" /> 
                        <label style="width: 100px;"id="dateimmo">Date Immoweb </label> 
                        <input name="dateimmo" type="text" style="width: 100px;"id="dateimmow" /> 
                        <label style="width: 100px;" id="dateexpir">Date expiration </label> 
                        <input name="dateexpir" type="text" style="width: 100px;" id="dateexpira" />
                    </p>
                    <p> Remarques :<textarea class="remarque" name="remarque" row="24" cols="45" style="height: 80px; width: 600px;"></textarea>
                </fieldset>
                <fieldset class="row2"> <legend>Plans </legend>
                    <p style="text-align: left;">* 
                        <label>Plan</label> 
                        <input name="plan" type="checkbox" value="oui" /> 
                        <label class="gender">Oui</label> 
                        <input name="plan" type="checkbox" value="non" /> 
                        <label class="gender">Non</label> </p>
     
     
                    <p> <label>Nouveau PDF</label> <input name="newpdf"style="width:100px;" type="text" class="long"  />
                        <label>Date reception</label> <input name="reception"style="width:100px;" type="text" />	</p>
                    <p> <label>Modif PDF </label> <input name="modif"style="width:100px;" type="text" class="long"  />
                        <label>Date creation</label> <input name="creation"style="width:100px;" type="text" />		</p>
                    <p> <label>Fichier plan</label> <input name="fichier"style="width:100px;" type="text" class="long" />
                        <label>Date agence</label> <input name="dateagence"style="width:100px;" type="text" /> </p>
                    <p> <label>Date corrections</label> <input name="correction"style="width:100px;" type="text" />
                        <label>Date publication</label> <input name="publication"style="width:100px;" type="text" /> </p>
     
                </fieldset>
                <fieldset class="row3"> <legend>Autre Informations </legend>
                    <p> <label>Numéro PEB</label> <input name="certifpeb"type="text"  /></p>
                    <p> <label> ID BDD</label> <input name="idbdd"type="text" /></p>
                    <p> <label> Photos </label> <input name="photo"type="text"/></p>
     
     
     
                                </fieldset>
     
                <div><input class="button" type="submit" value="Valider »"/></div>
     
            </form>
     
        </body>
    </html>
    j'ai du coup encore l'erreur à la ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $response->execute(array(':bien'=>$_POST['bien']));

  10. #10
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Tu as l'erreur après avoir validé le formulaire ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  11. #11
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    Non quand je valide j'ai tout mes champs vide
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    input name="bien" type="search" value="<?php echo htmlspecialchars($data['Code_bien']); ?> " style="width: 100px;" />
                    <label style="width: 100px;">Type de Vente</label>
                    <input type="text" name="typevente" value="<?php echo htmlspecialchars($data['Type_Vente']); ?> " style="width: 100px" />
    et sans l'erreur en haut de page.

  12. #12
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    j'ai testé de mille façon, mon champ Type_Vente ne ce remplis pas avec la requête.

  13. #13
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Fait un petit debug de base :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $data = $response->fetch(PDO::FETCH_ASSOC);
    var_dump($data);
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  14. #14
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    Notice: Undefined index: bien in C:\wamp\www\reponse3.php on line 40
    bool(false)

    Pourquoi me parle t il de booléen alors c'est un string ?

  15. #15
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Il faut valider ton formulaire, ce qui se passe avant la validation ne nous interesse pas.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  16. #16
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    c'est à dire ? je ne comprends pas

    Voila mon code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
     
    <head>
        <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
        <title>CSS Registration Form</title>
        <link rel="stylesheet" type="text/css" href="css/default.css" />
        <?php 
        try { 
        $bdd=new PDO( 'mysql:host=localhost;dbname=fiks;charset=utf8', 'ludo', ''); 
    } catch (Exception $e) 
    { die( 'Erreur : ' . $e->getMessage()); 
        } 
         //$bien = $_POST['bien'];
         $requete="SELECT 
        `Code_Bien`, 
        `Agence`, 
        `Type_Vente`, 
        `Type_Bien`, 
        `Date_Fiks`, 
        `Date_Immoweb`, 
        `Date_Expiration`, 
        `Actif`, 
        `Etat`, 
        `Certif_PEB`, 
        `Photos`, 
        `Plan`, 
        `PDF_Plan`, 
        `Modif_Plan`, 
        `Fichier_Plan`, 
        `Date_Reception`, 
        `Date_Creation`, 
        `Date_Envoie`, 
        `Date_Corrections`, 
        `Date_Publication`, 
        `Remarques` 
        FROM `biens`
      WHERE 'Code_Bien' = 'bien'";
    $response = $bdd->prepare($requete);
    $response->execute(array(':bien'=>$_POST['bien']));
    $data = $response->fetch(PDO::FETCH_ASSOC);
     
    var_dump($data);
     ?>
    </head>
     
    <body>
        <form method="post" action="reponse3.php"class="register">
            <h1>Consultation des Biens FIKS</h1>
            <fieldset class="row1">
                <legend>Détails du bien </legend>
                <p>
                    <label style="width: 100px;">Code bien </label>
                    <input name="bien" type="search" value="<?php echo htmlspecialchars($data['Code_bien']); ?> " style="width: 100px;" />
                    <label style="width: 100px;">Type de Vente</label>
                    <input type="text" name="typevente" value="<?php echo htmlspecialchars ($data['Type_Vente']); ?> " style="width: 100px" />
                    <label style="width: 100px;">Type de Bien </label>
                    <input type="text" name="typebien" style="width: 100px;" />
                    <p>
                        <label style="width: 100px;">Agence </label>
                        <input type="text" name="agence" style="width: 100px;" />
                        <label style="width: 100px;">Actif </label>
                        <input type="text" name="actif" style="width: 100px;"/>
                        <label style="width: 100px;">Etat </label>
                        <input type="text" name="etat" style="width: 100px;"/>
                    </p>
                    <p>
                        <label style="width: 100px;">Date fiks</label>
                        <input name="datefiks" type="text" style="width: 100px;" id="datefiks" />
                        <label style="width: 100px;" id="dateimmo">Date Immoweb </label>
                        <input name="dateimmo" type="text" style="width: 100px;" id="dateimmow" />
                        <label style="width: 100px;" id="dateexpir">Date expiration </label>
                        <input name="dateexpir" type="text" style="width: 100px;" id="dateexpira" />
                    </p>
                    <p> Remarques :
                        <textarea class="remarque" name="remarque" row="24" cols="45" style="height: 80px; width: 600px;"></textarea>
            </fieldset>
            <fieldset class="row2">
                <legend>Plans </legend>
                <p style="text-align: left;">
                    <label>Plan</label>
                    <input name="plan" type="checkbox" value="oui" />
                    <label class="gender">Oui</label>
                    <input name="plan" type="checkbox" value="non" />
                    <label class="gender">Non</label>
                </p>
                <p>
                    <label>Nouveau PDF</label>
                    <input name="newpdf" style="width:100px;" type="text" class="long" />
                    <label>Date reception</label>
                    <input name="reception" style="width:100px;" type="text" />
                </p>
                <p>
                    <label>Modif PDF </label>
                    <input name="modif" style="width:100px;" type="text" class="long" />
                    <label>Date creation</label>
                    <input name="creation" style="width:100px;" type="text" />
                </p>
                <p>
                    <label>Fichier plan</label>
                    <input name="fichier" style="width:100px;" type="text" class="long" />
                    <label>Date agence</label>
                    <input name="dateagence" style="width:100px;" type="text" />
                </p>
                <p>
                    <label>Date corrections</label>
                    <input name="correction" style="width:100px;" type="text" />
                    <label>Date publication</label>
                    <input name="publication" style="width:100px;" type="text" />
                </p>
            </fieldset>
            <fieldset class="row3">
                <legend>Autre Informations </legend>
                <p>
                    <label>Numéro PEB</label>
                    <input name="certifpeb" type="text" />
                </p>
                <p>
                    <label> ID BDD</label>
                    <input name="idbdd" type="text" />
                </p>
                <p>
                    <label> Photos </label>
                    <input name="photo" type="text" />
                </p>
            </fieldset>
            <div>
                <input class="button" type="submit" value="Valider »" />
            </div>
        </form>
    </body>
     
    </html>
    Je valide donc avec l'input button avec un from qui pointe la même page.

  17. #17
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Tu as mal recopié :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    WHERE Code_Bien = :bien"
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  18. #18
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    Oui merci .


    j'ai toujours Notice: Undefined index: bien in C:\wamp\www\forumu\reponse3.php on line 43 même après corrections.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $response->execute(array(':bien'=>$_POST['bien']));

  19. #19
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Comme je t'ai dis, c'est ce qui se passe après que tu aies validé le formulaire qui nous interesse.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  20. #20
    Membre à l'essai
    Homme Profil pro
    freelance
    Inscrit en
    Octobre 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : freelance

    Informations forums :
    Inscription : Octobre 2015
    Messages : 27
    Points : 10
    Points
    10
    Par défaut
    sachant que tout ce trouve dans la même page quand je valide je reviens sur cette page ci mais traité par mes requêtes ? enfin en théorie

    Quand je valide je suis supposé avoir toute les informations de mon bien via l'input search affiché dans les autre input avec un echo ( la je n'ai mis que le type de vente ) pour tester.

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. [AC-2000] afficher une requête dans un sous formulaire
    Par logidev dans le forum IHM
    Réponses: 2
    Dernier message: 18/06/2009, 11h22
  2. Afficher une HashMap dans un html:select
    Par ctagliam dans le forum Struts 1
    Réponses: 5
    Dernier message: 18/09/2007, 14h32
  3. Afficher une requéte dans un contenu HTML
    Par JiB@ dans le forum Requêtes et SQL.
    Réponses: 2
    Dernier message: 09/03/2007, 13h55
  4. [MySQL] Afficher une requête dans un champ texte
    Par SnickeursMan dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 24/11/2005, 10h07
  5. afficher une phrase dans le HTML a partir du javascript
    Par amelhog dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 18/08/2005, 17h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo