Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
www.volley92.asso.fr
/
htdocs
/
functions
/
/srv/data/web/vhosts/www.volley92.asso.fr/htdocs/functions/devis-home.php
<?php //Si le formulaire est rempli par un robot if(isset($_POST['pseudo']) && $_POST['pseudo']!="") header("Location: ".$routes['home']); //Init Variables $form_is_valid = true; $form_has_errors = false; $form_is_submitted = false; //how to use it $data = array( //'company' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Entreprise'), //'firstname' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Prénom'), 'lastname' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Nom'), //'address' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Adresse'), // 'zipcode' => array('value' => null,'status'=>null,'regex'=> _ZIPCODE_REGEX_, 'label'=>'Code postal'), //'city' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Ville','force_display'=>true), 'email' => array('value' => null,'status'=>null,'regex'=> _EMAIL_REGEX_, 'label'=>'E-mail'), 'phone' => array('value' => null,'status'=>null,'regex'=> _PHONE_REGEX_, 'label'=>'Téléphone'), 'adressdep' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Adresse de départ:'), 'adressarr' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Adresse d’arrivée:'), 'date1' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Date'), 'hour1' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Heure'), //'select1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Surface'), // 'checkbox1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Checkbox 1','force_display'=>true), // 'checkbox2' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Checkbox 2','force_display'=>true), // 'checkbox3' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Checkbox 3','force_display'=>true), // 'radio1' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=> array('title'=>'Radio 1','options'=>array('option1'=>'Option 1','option2'=>'Option 2'))), // 'input1' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Input 1'), // 'amount1' => array('value' => null,'status'=>null,'regex'=> _AMOUNT_REGEX_, 'label'=>'Montant 1'), // 'date1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Date 1'), //'message' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Informations complémentaire (facultatif)'), //'file' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Pièce jointe'), //'pseudo' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Pseudo'), ); //Formulaire envoyé if(isset($_POST['devis'])) { //echo"form poste"; // $data['address']['value'] = (isset($_POST['address']))?$_POST['address']:null; // $data['amount1']['value'] = (isset($_POST['amount1']))?$_POST['amount1']:null; //$data['city']['value'] = (isset($_POST['city']))?$_POST['city']:null; // $data['checkbox1']['value'] = (isset($_POST['checkbox1']))?$_POST['checkbox1']:null; // $data['checkbox2']['value'] = (isset($_POST['checkbox2']))?$_POST['checkbox2']:null; // $data['checkbox3']['value'] = (isset($_POST['checkbox3']))?$_POST['checkbox3']:null; // $data['company']['value'] = (isset($_POST['company']))?$_POST['company']:null; // $data['date1']['value'] = (isset($_POST['date1']))?$_POST['date1']:null; $data['email']['value'] = (isset($_POST['email']))?$_POST['email']:null; //$data['firstname']['value'] = (isset($_POST['firstname']))?$_POST['firstname']:null; // $data['file']['value'] = (isset($_FILES['file']))?$_FILES['file']:null; // $data['input1']['value'] = (isset($_POST['input1']))?$_POST['input1']:null; $data['lastname']['value'] = (isset($_POST['lastname']))?$_POST['lastname']:null; $data['adressdep']['value'] = (isset($_POST['adressdep']))?$_POST['adressdep']:null; $data['adressarr']['value'] = (isset($_POST['adressarr']))?$_POST['adressarr']:null; //$data['message']['value'] = (isset($_POST['message']))?$_POST['message']:null; $data['phone']['value'] = (isset($_POST['phone']))?$_POST['phone']:null; $data['date1']['value'] = (isset($_POST['date1']))?$_POST['date1']:null; $data['hour1']['value'] = (isset($_POST['hour1']))?$_POST['hour1']:null; //$data['pseudo']['value'] = (isset($_POST['pseudo']))?$_POST['pseudo']:null; //$data['radio1']['value'] = (isset($_POST['radio1']))?$_POST['radio1']:null; // $data['select1']['value'] = (isset($_POST['select1']))?$_POST['select1']:null; //$data['zipcode']['value'] = (isset($_POST['zipcode']))?$_POST['zipcode']:null; $form_is_submitted = true; //Form validation rules foreach($data as $key => $field) { if (!is_null($field['regex'])){ if (validate($field['regex'],$field['value'])){$data[$key]['status'] = 'has-success';} else{$data[$key]['status'] = 'has-error';$form_is_valid = false;} } } if ($form_is_valid) { //validation rules are OK //Filling my product field foreach($data as $field => $params) { //just fill the 'demande' section of the order if(!in_array($field,array('lastname','email','phone','adressdep','adressarr'))) { //search for checkboxN and fill it with Oui (checked) or No (unchecked) if(substr($field, 0, 8) == 'checkbox') { $product[$params['label']] = ($params['value'])?'Oui':'Non'; } //search for radio and fill it with the checked option label elseif(substr($field, 0, 5) == 'radio'){ $product[$params['label']['title']] = $params['label']['options'][$params['value']]; } //fill all the remain fields into products else{ $product[$params['label']] = $params['value']; } } } $form_data = array( //$data['firstname']['value'], $data['lastname']['value'], $data['email']['value'], $data['phone']['value'], $data['adressdep']['value'], $data['adressarr']['value'], //$data['company']['value'], //$data['address']['value'], //$data['zipcode']['value'], //$data['city']['value'], //$data['message']['value'], serialize($product), $conf_id_company, ); //insert form in db // include "config/database_forms.php"; // $stmt = $db_forms->prepare("INSERT INTO devis_client(lastname,email,phone,zipcode,product,send_at,id_company) VALUES (?,?,?,?,?,NOW(),?)"); //$stmt->execute($form_data); //$db_forms = null;//deconnexion de la db //Send emails mailDevis($data); mailConfirmation($data); header("Location: " . $routes['devis-success']); }else{ //On affichera un message d'erreur $form_has_errors = true; } }