salut mon probleme c'est que j'ai un formulaire avec deux champs(nom, mail) nommé inscription et j'ai ecriture.php qui contient l'ajout dans la table
j'ai integrer l'intermidiere ajax pour que la page ne se charge pas le probleme que j'arrive pas a passer des variable en js vers php
voila mon code
inscription.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 function ajax(page,cible) { var xhr=null; if(window.XMLHttpRequest) { xhr=new XMLHttpRequest; } if(window.ActiveXObject) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.onreadystatechange= function() { if (xhr.readyState == 4) { document.getElementById(cible).innerHTML=xhr.responseText; } } xhr.open('GET',page,true); xhr.send(null) }
ecriture.php
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 id="form1" name="form1" method="post" action="ecriture.php" onsubmit="return control()"> <table width="96%" height="50" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="30%"> <span class="Style2">Nom</span></td> <td width="70%"><label> <input name="nom" type="text" class="Style2" id="nom" /> </label></td> </tr> <tr> <td height="38"> <span class="Style2">E-mail</span></td> <td height="38"><label> <input name="mail" type="text" class="Style2" id="mail" /> </label></td> </tr> <tr> <td height="33"> </td> <td valign="top"><label> <div align="center"> <label> <input name="valider" type="submit" id="valider" value="inscrivez vous" class="button1" onmouseover="vert()" onmouseout="bleu()" onclick="ajax('ecriture.php', 'newslettre'); return false" /> </label> <br /> <label></label> <label></label> <label></label> </div> </label></td> </tr> </table> </form>
le problem c'est qu'il me fais l'ajout dans la table mais il m'affiche pas le tableau inclu dans ecriture.php (votre inscription a été ajouté avec succe
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 <?php $host = "localhost"; // voir hébergeur $user = "root"; // vide ou "root" en local $pass = ""; // vide en local $bdd = "newslettre"; // nom de la BD @mysql_connect($host,$user,$pass) or die("Impossible de se connecter avec le serveur"); @mysql_select_db("$bdd") or die("Impossible de se connecter avec La base de données"); if (isset($_POST['valider'])) { $nom=stripslashes($_POST['nom']); //Nom $mail=stripslashes($_POST['mail']); //mail $date=date('y/m/d'); if(!empty($nom) && !empty($mail)) { $sql="insert into client values('', '$nom', '$mail', '$date')"; mysql_query($sql) or die("erreur l'ajout des donnee". mysql_error()); ?> <table width="28%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td height="19" colspan="2"><label></label> <label></label> <label> </label> <div align="center" class="stylnomdomain">Etat d'envoi </div></td> </tr> <tr> <td width="21%" height="113" class="Style4"><img src="images/ok.png" width="58" height="57" /></td> <td width="79%" height="113" class="Style4"><div align="center"><br /> Votre Inscription a été ajouté avec sucée<br /> <br /> <a href="index.php" onclick="ajax('index.php', 'newslettre'); return false">Retour</a></div></td> </tr> </table> <?php mysql_close(); } } ?>) svp aidez moi sur ca
![]()
Partager