Bonjour,

Comme dit dans l'intitulé, j'ai un petit soucis pour récupérer des données.

J'ai un fichier emails.liste.html ou j'ai mon formulaire et mes données en jquery et un autre fichier ou je transmet les données pour qu'elles soient traités : emails.php :

emails.liste.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
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
$( "#dialog-form" ).dialog({
			autoOpen: false,
			height: 520,
			width: 400,
			modal: true,
			buttons: {
				"Créer un compte": function() {
					/*var bValid = true;
					allFields.removeClass( "ui-state-error" );
 
					bValid = bValid && checkLength( nom, "nom", 2, 20 );
					bValid = bValid && checkLength( prenom, "prenom", 2, 20 );
					bValid = bValid && checkLength( adresse, "adresse", 5, 40 );
                    bValid = bValid && checkLength( code_postal, "code_postal", 3, 16 );
					bValid = bValid && checkLength( ville, "ville", 5, 16 );
					bValid = bValid && checkLength( telephone, "telephone", 5, 16 );
					bValid = bValid && checkLength( email, "email", 6, 80 );
 
 
					bValid = bValid && checkRegexp( nom, /^[a-z]([0-9a-z_])+$/i, "Le nom of a-z, 0-9, underscores, begin with a letter." );
					bValid = bValid && checkRegexp( prenom, /^[a-z]([0-9a-z_])+$/i, "Le prenom may consist of a-z, 0-9, underscores, begin with a letter." );
					bValid = bValid && checkRegexp( adresse, /^[a-z]([0-9a-z_])+$/i, "l'adresse may consist of a-z, 0-9, underscores, begin with a letter." );
					bValid = bValid && checkRegexp( code_postal, /^([0-9])+$/, "Le mote de passe field only allow : 0-9" );
					bValid = bValid && checkRegexp( ville, /^[a-z]([0-9a-z_])+$/i, "La ville may consist of a-z, 0-9, underscores, begin with a letter." );
					bValid = bValid && checkRegexp( telephone, /^([0-9])+$/, "Le telephone field only allow : 0-9" );
					bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );
					*/
				/*	if ( bValid )
					{*/
 
						$( "#users" ).append( "<tr>" +
							"<td>" + nom.val() + "</td>" +
							"<td>" + prenom.val() + "</td>" +
							"<td>" + code_postal.val() + "</td>" +
							"<td>" + ville.val() + "</td>" +
							"<td>" + telephone.val() + "</td>" +
							"<td>" + email.val() + "</td>" +
							"<td>" + groupe.val() + "</td>" +
						"</tr>" );
 
 
 
					//var data = $("#dialog-form > form" ).serialize();
					//alert (data);
					$.ajax({
					 type: "POST",
					 url: "/modules/emails.php",
					 data: $("#dialog-form form" ).serialize(),
					 success: function(msg){
					     alert( "Data Saved: " + msg );
					     info_good("Le nouveau contact a bien été crée");
					   }
 
 
					});
 
								$( this ).dialog( "close" );
 
 
 
				/*	}*/
 
 
 
 
											},
					Annuler: function()
					 {
							$( this ).dialog( "close" );
					 }
 
 
 
					},

emails.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
33
34
35
36
37
38
39
40
41
42
43
44
	print_r($_POST);
	 //echo $_POST['prenom'];
 
		// ajout d'un enregistrement
	if(!empty($_POST['nom']) AND !empty($_POST['prenom']))
	{
		echo $_POST['prenom'];
		// sécurisation
		$nom = addslashes(strip_tags(trim($_POST['nom'])));
		$prenom = addslashes(strip_tags(trim($_POST['prenom'])));
		$adresse = addslashes(strip_tags(trim($_POST['adresse'])));
		$code_postal = $_POST['code_postal'];
		$ville = addslashes(strip_tags(trim($_POST['ville'])));
		$pays = addslashes(strip_tags(trim($_POST['pays'])));
		$telephone = $_POST['telephone'];
		$email = addslashes(strip_tags(trim($_POST['email'])));
		$abonne = 1;
		$groupe = (int)$_POST['groupe'];
 
 
 
		// enregistrement
		$sql = "INSERT INTO emails ( nom, prenom, adresse, code_postal, ville, pays, telephone, email, abonne, groupes_id )
				VALUES ('$nom', '$prenom', '$adresse', '$code_postal', '$ville', '$pays', '$telephone', '$email', '$abonne', '$groupe');";
 
				echo $sql;
				exit;
 
			if($db->query($sql))
			{
				$tpl->assign_block_vars('msgbox', array(
					'icone' => 'info',
					'msg' 	=> "L'email a été ajouté."
			));
 
	 		}
			else
			{
				$tpl->assign_block_vars('msgbox', array(
					'icone' => 'error',
					'msg' 	=> "Une erreur est survenue."
			));
			}
 	}
Alors quand je valide mon formulire j'ai bien les données passées en post mais je n'ai aucune insertion ?? Bizarre.

Quand je passe par un serialize et que je n'ai pas une fonction de retour por insérer les données dans ma base.

Merci