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/form-inscription.php
<?php //Si le formulaire est rempli par un robot if(isset($_POST['pseudo']) && $_POST['pseudo']!="") header("Location: ".$routes['devis-success']); //Init Variables $form_is_valid = true; $form_has_errors = false; $form_has_errors_trajet = false; $form_is_submitted = false; $form_has_errors_cgv = false; $form_has_errors_rgpd = false; //SI formualire pré devis : //how to use it $data = array( // 'company' => array('value' => null,'status'=>null,'regex'=> null, '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'), 'formation' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Formation'), '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'), 'pseudo' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Pseudo'), 'rgpd' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'En utilisant ce formulaire, vous acceptez le stockage et la gestion de vos données par ce site *','force_display'=>true), 'cgv' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'J\'accepte les conditions générales de vente *','force_display'=>true), // 'zipcode' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Code postal'), // 'city' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Ville','force_display'=>true), // 'checkbox1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Aller simple','force_display'=>true), // 'checkbox2' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Aller/Retour','force_display'=>true), // 'select1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Nombre de passagers'), //'amount1' => array('value' => null,'status'=>null,'regex'=> _AMOUNT_REGEX_, 'label'=>'Montant 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'), // 'checkbox1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Je m’inscris à la newsletter','force_display'=>true), ); //Formulaire envoyé if(isset($_POST['inscription'])) { //echo '<pre>'; var_dump($_POST); echo '</pre>'; // if(!isset($_POST['checkbox1']) && !isset($_POST['checkbox2'])){ // $form_has_errors_trajet = true; // $form_is_valid = false; // } if (empty($_POST['rgpd'])) { $form_has_errors_rgpd = true; $form_is_valid = false; } $data['firstname']['value'] = (isset($_POST['firstname']))?$_POST['firstname']:null; $data['lastname']['value'] = (isset($_POST['lastname']))?$_POST['lastname']:null; $data['email']['value'] = (isset($_POST['email']))?$_POST['email']:null; $data['phone']['value'] = (isset($_POST['phone']))?$_POST['phone']:null; $data['formation']['value'] = (isset($_POST['formation']))?$_POST['formation']:null; // $data['address']['value'] = (isset($_POST['address']))?$_POST['address']:null; // $data['address2']['value'] = (isset($_POST['address2']))?$_POST['address2']:null; //$data['amount1']['value'] = (isset($_POST['amount1']))?$_POST['amount1']:null; // $data['city']['value'] = (isset($_POST['city']))?$_POST['city']:null; // $data['company']['value'] = (isset($_POST['company']))?$_POST['company']:null; // $data['date1']['value'] = (isset($_POST['date1']))?$_POST['date1']:null; // $data['date2']['value'] = (isset($_POST['date2']))?$_POST['date2']:null; // $data['checkbox1']['value'] = (isset($_POST['checkbox1']))?$_POST['checkbox1']:null; // $data['checkbox2']['value'] = (isset($_POST['checkbox2']))?$_POST['checkbox2']:null; //$data['file']['value'] = (isset($_FILES['file']))?$_FILES['file']:null; // $data['hour1']['value'] = (isset($_POST['hour1']))?$_POST['hour1']:null; // $data['hour2']['value'] = (isset($_POST['hour2']))?$_POST['hour2']:null; // $data['select1']['value'] = (isset($_POST['select1']))?$_POST['select1']:null; // $data['message']['value'] = (isset($_POST['message']))?$_POST['message']:null; //$data['rgpd']['value'] = (isset($_POST['rgpd']))?$_POST['rgpd']:null; // $data['pseudo']['value'] = (isset($_POST['pseudo']))?$_POST['pseudo']:null; // $data['radio1']['value'] = (isset($_POST['radio1']))?$_POST['radio1']:null; // $data['select2']['value'] = (isset($_POST['select2']))?$_POST['select2']: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;} } } //file check //if(is_null($data['file']['value']) || file_is_uploaded($data['file']['value'])){$data['file']['status'] = 'has-success';} //else{$data['file']['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('company','firstname','lastname','phone','formation','pseudo'))) { //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['formation']['value'], $data['phone']['value'], $data['email']['value'], // $data['zipcode']['value'], // $data['city']['value'], // $data['select1']['value'], // $data['input1']['value'], ); $db_forms = null;//deconnexion de la db //Send emails mailInscription($data); mailConfirmationInscription($data); header("Location: " . $routes['inscription-success']); }else{ //On affichera un message d'erreur $form_has_errors = true; } }