Bonjour,

voici un script pour la saisie de formulaire où je souhaite ajouter la récupération des coordonnées gps et les envoyer par email avec le formulaire found pet

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
 
                    $uploadOk = 0;
                }
                // Allow certain file formats
                if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
                   && $imageFileType != "gif" ) {
                    return "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
                    $uploadOk = 0;
                }
                // Check if $uploadOk is set to 0 by an error
                if ($uploadOk == 0) {
                  return "Sorry, your file was not uploaded.";
                  // if everything is ok, try to upload file
                } else {
                    if (move_uploaded_file($fileToUpload["tmp_name"], $target_dir.$filename.".".$imageFileType)) {
                        return true;
                    } else {
                        return "Sorry, there was an error uploading your file.";
                    }
                }
            }
 
        }
 
        function contact($name, $firstName, $address, $postalCode, $city, $country, $phoneNumber, $email, $comment, $tag){
            $mysqli = new mysqli("");
            $result = $mysqli->query("SELECT id FROM tags WHERE code='".$tag."'");
            if($row = $result->fetch_array()){
                $name = utf8_decode($name);
                $firstName = utf8_decode($firstName);
                $address = utf8_decode($address);
                $postalCode = utf8_decode($postalCode);
                $city = utf8_decode($city);
                $country = utf8_decode($country);
                $phoneNumber = utf8_decode($phoneNumber);
                $email = utf8_decode($email);
                $comment = utf8_decode($comment);
                $result = $mysqli->query("SELECT id_info FROM info_tags WHERE id_tag=".$row['id']);
                if($rowInfo = $result->fetch_array()){
                    $resultInfo = $mysqli->query("SELECT email, name FROM informations WHERE id=".$rowInfo['id_info']);
                    if($rowInfoo = $resultInfo->fetch_array()){
                        $stmt = $mysqli->prepare("INSERT INTO contact (name, firstName, address, postalCode, city, country, phoneNumber, email, comment, id_info) VALUES (?,?,?,?,?,?,?,?,?,?)");
 
                        $stmt->bind_param('sssssssssi',
                                          $name,
                                          $firstName,
                                          $address,
                                          $postalCode,
                                          $city,
                                          $country,
                                          $phoneNumber,
                                          $email,
                                          $comment,
                                          $rowInfo['id_info']);
 
                        $stmt->execute();
 
                        // Plusieurs destinataires
                        $to = $rowInfoo['email'];
 
                        // Sujet
                        $subject = $rowInfoo['name']." found";
 
                        // message
                        $message = '
                        <html>
                          <body>
                            <p>'.$rowInfoo['name'].' was found!</p>
                            <table>
                              <tr>
                                <td>Name</td>
                                <td>'.$name.'</td>
                              </tr>
                              <tr>
                                <td>First name</td>
                                <td>'.$firstName.'</td>
                              </tr>
                              <tr>
                                <td>Address</td>
                                <td>'.$address.'</td>
                              </tr>
                              <tr>
                                <td>Postal code</td>
                                <td>'.$postalCode.'</td>
                              </tr>
                              <tr>
                                <td>City</td>
                                <td>'.$city.'</td>
                              </tr>
                              <tr>
                                <td>Country</td>
                                <td>'.$country.'</td>
                              </tr>
                              <tr>
                                <td>Phone number</td>
                                <td>'.$phoneNumber.'</td>
                              </tr>
                              <tr>
                                <td>Mail</td>
                                <td>'.$mail.'</td>
                              </tr>
                              <tr>
                                <td>Comment</td>
                                <td>'.$comment.'</td>
                              </tr>
                            </table>
                          </body>
                        </html>
                        ';
 
                        // Pour envoyer un mail HTML, l'en-tête Content-type doit être défini
                        $headers = 'MIME-Version: 1.0' . "\r\n";
                        $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
 
                        // En-têtes additionnels
                        $headers .= 'To: '. $rowInfoo['email'] . "\r\n";
                        $headers .= 'From: found@petminion.com' . "\r\n";
 
                        // Envoi
                        mail($to, $subject, $message, $headers);
                    }
 
                }
 
            }
        }