-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.php
66 lines (53 loc) · 1.99 KB
/
contact.php
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
<?php
$response = array(
'status' => '',
'message' => ''
);
if(!empty($_POST['nom']) && !empty($_POST['email']) && !empty($_POST['message'])) {
if(strlen($_POST['nom']) < 41 && strlen($_POST['email']) < 41 && strlen($_POST['message']) < 350) {
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$nom = filter_var($_POST['nom'], FILTER_SANITIZE_STRING);
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$objet = filter_var($_POST['objet'], FILTER_SANITIZE_STRING);
$message = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
$userip = $_SERVER['REMOTE_ADDR'];
require_once('php/config.php');
$insert = $mysql->prepare("INSERT INTO `contact_form`(`userip`, `date`, `nom`, `email`, `objet`, `message`) VALUES (:userip, now(), :nom, :email, :objet, :message)");
$insert->execute(array(
':userip'=>$userip,
':nom'=>$nom,
':email'=>$email,
':objet'=>$objet,
':message'=>$message
));
if($insert)
{
// require('php/user-mail-confirmation.php');
require('php/alert-mail-contact.php');
// confirm_candidature();
// alert_candidature($name_file);
$response['status'] = 'success';
$response['message']='Le formulaire a bien été envoyé ! ';
}
else
{
$response['message']='Désolé le service a rencontré un problème interne ! ';
}
}
else
{
$response['message']='Veuillez renseigner une email valide !';
}
}
else
{
$response['message']='Merci de ne pas tenter de nous spamer ! ';
}
}
else
{
$response['message']='Veuillez compléter tous les champs ! ';
}
echo json_encode($response);
header('Content-type: application/json');
?>