Bonjour
j' ai un problème avec mon code je travaille sur un projet et j aimerai résoudre ce problème
voici le code de ma forme les champs sont dans un tableau, mais quand je clic sur le bouton valider le code php ne recupere pas les valeurs des champs vous trouverez le code php du bouton valider un peu plus bas.
Code html : 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 <form action="carriere.php" method="post" enctype="multipart/form-data" target="_self"> <table class="art-article" style="width: 100%; "> <tbody> <tr><td style="width: 100%; " colspan="2"><br> <font color="black" size="3px">Civilité <span style="color: rgb(255, 0, 0); font-weight: bold; ">* </span>:<br> <select NAME="textchoix1" required> <option selected>choisissez..</option> <option value="Mr" checked>Mr</option> <option value="Mm">Mm</option> <option value="Mlle">Mlle</option> </select></font> <br></td></tr> <tr><td style="width: 50%; "><font color="black" size="3px">Nom <span style="color: rgb(255, 0, 0); font-weight: bold; ">* </span>: <br><INPUT NAME="textnom" VALUE="" SIZE=30 required></font> <br></td> <td style="width: 50%; "><font color="black" size="3px">Prénom <span style="color: rgb(255, 0, 0); font-weight: bold; ">* </span>: <br><INPUT NAME="textprenom" VALUE="" SIZE=30 required></font><br></td> </tr> <tr><td style="width: 50%; "><font color="black" size="3px">Téléphone <span style="color: rgb(255, 0, 0); font-weight: bold; ">* </span>: <br><INPUT NAME="texttel" type="text" placeholder="Exemple:068630644" min=0 maxlength="9" id="tel" onchange="verif_tel()" SIZE=30 required></font><br></td> <td style="width: 50%; "><font color="black" size="3px">E-mail <span style="color: rgb(255, 0, 0); font-weight: bold; ">* </span>: <br><INPUT type="textemail" NAME="email" VALUE="" SIZE=30 required></font><br></td> </tr> <tr> <td style="width: 50%; "><font color="black" size="3px">Adresse <span style="color: rgb(255, 0, 0); font-weight: bold; ">* </span>: <br><INPUT NAME="textadr" VALUE="" SIZE=30 required></font><br></td> <td style="width: 50%; "><font color="black" size="3px">Ville <span style="color: rgb(255, 0, 0); font-weight: bold; ">* </span>: <br><INPUT NAME="textville" VALUE="" SIZE=30 required></font><br></td> </tr> <tr><td style="width: 100%; " colspan="2"><br><font color="black" size="3px"><legend>Votre candidature :</legend></font> <br><font color="black" size="3px">Motif de votre candidature<span style="color: rgb(255, 0, 0); font-weight: bold; ">*</span> : <br><select NAME="textchoix2" required> <option selected>précisez.</option> <option value="Recherche_emploi">Recherche d'emploi</option> <option value="Recherche_stage">Recherche de stage</option> </select></font> <br></td> </tr> <tr><td style="width: 100%; " colspan="2"><font color="black" size="3px"><legend><br></legend><legend>Votre curriculum vitea :</legend><legend><br></legend> <legend>Votre motivation : <br><textarea placeholder="veuillez choisir l'une des motivation suivantes: Je suis dynamique, je suis travailleur, je suis ambitieux, je suis bavard, je suis provocateur, je suis insupportable)" name="textlettre" cols=70 rows=8 ></textarea></legend></font><br> </td></tr><tr><td style="width: 100%; " colspan="2"><font color="black" size="3px"><font color="black" size="3px">Votre curriculum vitea<span style="color: rgb(255, 0, 0); font-weight: bold; ">*</span> : <INPUT TYPE="file" NAME="textfichier" SIZE="50" required></font></font><br></td> </tr><tr> <td style="width: 100%; " colspan="2"> <INPUT TYPE=SUBMIT name="carriere" VALUE="Envoyer" class="art-button"> <input type="reset" value="Initialiser" class="art-button"/> <!--<a href="" class="art-button">Envoyer</a> <a href="" class="art-button">Initialiser</a> --> </td></tr> </tbody> </table> </form>
execution du code php apres le clic sur le bouton valider
Code php : 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 <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "j.bouka@de-network.fr"; $email_subject = "Information Carriere venant du site De-Network"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['textchoix1']) || !isset($_POST['textnom']) || !isset($_POST['textprenom']) || !isset($_POST['texttel']) || !isset($_POST['email']) || !isset($_POST['textadr']) || !isset($_POST['textville']) || !isset($_POST['textchoix2']) || !isset($_POST['textlettre']) || !isset($_POST['textfichier'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $Civilite = $_POST['textchoix1']; // required $nom = $_POST['textnom']; // required $prenom = $_POST['textprenom']; // required $telephone = $_POST['texttel']; // required $email_from = $_POST['email']; // required $adresse = $_POST['textadr']; // not required $ville = $_POST['textville']; // required $candidature = $_POST['textchoix2']; // required $lettre = $_POST['textlettre']; // required $fichier = $_POST['textfichier']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'L Adresse mail est invalide .<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$Civilite)) { $error_message .= ' La Civilité est incorrect.<br />'; } if(!preg_match($string_exp,$nom)) { $error_message .= 'Le nom est incorrect.<br />'; } if(!preg_match($string_exp,$prenom)) { $error_message .= 'Le prénom est invalide.<br />'; } if(!preg_match($string_exp,$telephone)) { $error_message .= 'Le numero de telephone est invalide.<br />'; } if(!preg_match($string_exp,$adresse)) { $error_message .= 'L adresse est invalide.<br />'; } if(!preg_match($string_exp,$ville)) { $error_message .= 'Le nom de la ville est incorrect.<br />'; } if(!preg_match($string_exp,$candidature)) { $error_message .= 'La Candidature est invalide.<br />'; } if(strlen($lettre) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Civilité: ".clean_string($Civilite)."\n"; $email_message .= "Nom: ".clean_string($nom)."\n"; $email_message .= "Prénom: ".clean_string($prenom)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Adresse: ".clean_string($adresse)."\n"; $email_message .= "Ville: ".clean_string($ville)."\n"; $email_message .= "Candidature: ".clean_string($candidature)."\n"; $email_message .= "Lettre de Motivation: ".clean_string($lettre)."\n"; $email_message .= "C.V: ".clean_string($fichier)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <script language="JavaScript" type="text/JavaScript"> alert("Votre message à bien été envoyé"); window.location.href="contact.php"; </script> <?php } ?>
Partager