Bonjours,
Voici mon souci j'aimerais afficher mon textearea puis mon bouton envoyer après pression du bouton recherche car mon problème étant que lorsque je presse ce fameux bouton "recherche" après l’exécution du code php il actualise la page et donc recache mon textarea et mon bouton.
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 <?php error_reporting(null); if (isset($_POST['bouton_recherche'])) { try { $bdd = new PDO('mysql:host=localhost;dbname=gestion_compte;charset=utf8', 'root', ''); } catch(Exception $e) { die('Erreur : '.$e->getMessage()); } $nom = $_POST['nom']; $reponse = $bdd->query('SELECT * FROM conge WHERE nom_dusage="'.$nom.'"'); $donnees = $reponse->fetch(); $prenom = $donnees['prenom']; $ok = $_POST['textarea']; } ?> <?php if(isset($_POST['recherche2'])) { try { $bdd = new PDO('mysql:host=localhost;dbname=gestion_compte;charset=utf8', 'root', ''); } catch(Exception $e) { die('Erreur : '.$e->getMessage()); } $reponse = $bdd->query('SELECT * FROM conge WHERE nom_dusage="'.$nom.'"'); $donnees = $reponse->fetch(); $prenom = $donnees['prenom']; $ok = $_POST['textarea']; $nom = $_POST['nom']; $nb_modifs = $bdd->exec('UPDATE conge SET prenom = "'.$ok.' "WHERE nom_dusage = "'.$nom.'"'); } ?> <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(".btn1").click(function(){ $("#cacher").show(); }); }); </script> <style> #cacher { visibility: hidden; } </style> <form method='post' action='test.php'> Nom d'usage : <input type="text" name="nom" id="nom_dusage" value="<?php if (isset($_POST['nom'])) { echo htmlspecialchars($_POST['nom']) ; } ?>" /> <button name="bouton_recherche" class="btn1"> Recherche </button> <button class='buttonr' name = 'recherche2' id="cacher">Envoyer</button> <textarea name='textarea' rows="20" cols="40" id="cacher"> <?php echo"$prenom" ?> </textarea> </form> </body> </html>
PS : Merci de vos réponse à l'avance
Partager