Page MenuHomeDevCentral
Paste P112

modScript.php
ActivePublic

Authored by dereckson on Aug 30 2015, 09:35.
Tags
None
Referenced Files
F7408: modScript.php
Aug 30 2015, 09:35
Subscribers
None
<?php
# *************************************************************************
# * Initialisationes des tableaux de libellés utilisés dans le formulaire *
# * pour les radio, checkbox et select *
# *************************************************************************
#
# Pour le radiotype_de_champ : Loisirsname_du_champ
#
$tabLibellesLoisirs = array
(
"Golf",
"Danse",
"Basket",
"Football",
"Crocket",
"Echecs"
);
# Pour le SelectMultiple_type_de_champ : Paysname_du_champ
$tabLibellesPays = array
(
'',
"Belgique",
"France",
"Italie",
"Vatican",
"USA"
);
#
# ***************************************************************************
# * Initialisations de valeurs attendues pour les radio, checkbox et select *
# ***************************************************************************
#
# Pour le xxxtype_de_champ : xxxname_du_champ
#
for($i = 1; $i <= 5; $i++)
{
$valpays[] = $i;
}
for($i = 1; $i <= 6; $i++)
{
$valloisirs[] = $i;
}
# **************************************************
# * Dans quel état dois-je envoyer le formulaire ? *
# **************************************************
#
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Formulaire initial
#
$legende = 'Entrer les données';
include('fonctions02.php');
if(empty($_GET)) // ou $_POST
{
#
# Initialisation des variables
#
$loisirs_name = ''; // pour une variable "normale"
$pays_name = array(); // pour un array
$notification = '<h1>Veuillez completer le formulaire</h1>';
}
else
{
#
# >>>>>>>>>>>>>>>>>>>>>>>>>>>> Formulaire soumis
#
include('fonctions01.php');
#
# Extraction des données
#
$identite_name = @trim($_GET['identite']);
$loisirs_name = @$_GET['loisirs'];
$pays_name = @$_GET['pays']; // pas de trim() pour un array
$notification = '';
#
# *********************************
# * Validation des données reçues *
# *********************************
#
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Valeurs attendues
#
if (valAttendues($valloisirs, $loisirs_name) == false)
{
$loisirs_name = '';
}
if (valAttendues($valpays, $pays_name) == false)
{
$pays_name = '';
}
#
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Champs obligatoires
#
$tabChampsOblig = array(
'identite_name' => 'identite, ',
'loisirs_name' => 'loisirs, ',
'pays_name' => 'pays, '
);
$notificationObligTitre = '<h1>Veuillez compléter les champs suivants:</h1>';
$notificationObligTexte = '';
$statutObligOK = true;
foreach ($tabChampsOblig as $key => $value)
{
if(empty($$key))
{
$notificationObligTexte .= $tabChampsOblig[$key];
$statutObligOK = false;
}
}
if($statutObligOK == false)
{
$notificationObligTexte = trim($notificationObligTexte, " \t\n\r\0\x0B,");
$notificationObligTexte .= '.';
$notificationObligTexte = '<p>'.$notificationObligTexte.'</p>';
$notification .= $notificationObligTitre . $notificationObligTexte;
}
#
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Champs textes
#
$tabChampsTexte = array(
'identite_name' => 'identite, ');
$notificationTexteTitre = '<h1>Ces chaînes contiennent des caractères non valides:</h1>';
$notificationTexteTexte = '';
$statutTexteOK = true;
foreach ($tabChampsTexte as $key => $value)
{
if(estUnTexte($$key) == false)
{
$notificationTexteTexte .= $tabChampsTexte[$key];
$statutTexteOK = false;
}
}
if($statutTexteOK == false)
{
$notificationTexteTexte = trim($notificationTexteTexte, " \t\n\r\0\x0B,");
$notificationTexteTexte .= '.';
$notificationTexteTexte = '<p>'. $notificationTexteTexte. '</p>';
$notification .= $notificationTexteTitre . $notificationTexteTexte;
}
}
if ($notification == '')
{
$notification = '<h1>Vos données ont été validées et enregistrées.</h1>';
$actif_inactif = 'disabled = "disabled"';
}
else
{
$actif_inactif = '';
}
include 'modForm.php';
?>

Event Timeline

dereckson changed the title of this paste from untitled to modScript.php.
dereckson updated the paste's language from autodetect to autodetect.