1 |
aurelien |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
$erreurs = array();
|
|
|
4 |
|
|
|
5 |
include("connect.php");
|
|
|
6 |
include_once 'configuration/car_config.inc.php' ;
|
|
|
7 |
include("messages.php");
|
|
|
8 |
|
|
|
9 |
if (!PARTICIPANT_EST_ADULTE) {
|
|
|
10 |
echo '<script language="javascript">
|
|
|
11 |
|
|
|
12 |
function changementType() {
|
|
|
13 |
if (document.forms[\'form_inscription\'].elements[\'type_inscription\'].value==\'1\') {
|
|
|
14 |
document.forms[\'form_inscription\'].elements[\'ecole\'].disabled = false;
|
|
|
15 |
document.forms[\'form_inscription\'].elements[\'ecole\'].className = "";
|
|
|
16 |
document.forms[\'form_inscription\'].elements[\'niveau\'].disabled = false;
|
|
|
17 |
document.forms[\'form_inscription\'].elements[\'niveau\'].className = "";
|
|
|
18 |
}
|
|
|
19 |
else {
|
|
|
20 |
document.forms[\'form_inscription\'].elements[\'ecole\'].disabled = true;
|
|
|
21 |
document.forms[\'form_inscription\'].elements[\'ecole\'].className = "disabled";
|
|
|
22 |
document.forms[\'form_inscription\'].elements[\'niveau\'].disabled = true;
|
|
|
23 |
document.forms[\'form_inscription\'].elements[\'niveau\'].className = "disabled";
|
|
|
24 |
}
|
|
|
25 |
}
|
|
|
26 |
</script>
|
|
|
27 |
';
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
/**** A-t-on demandé à s'inscrire ? ****/
|
|
|
31 |
if (isset($_POST['valid'])) {
|
|
|
32 |
//Vérification de l'adresse mail
|
|
|
33 |
if ($_POST['mail']!=$_POST['mail_confirm'])
|
|
|
34 |
$erreurs[] = $mail_invalide;
|
|
|
35 |
|
|
|
36 |
//Verification des champs obligatoires
|
|
|
37 |
if (!$_POST['pseudo'])
|
|
|
38 |
$erreurs[] = $pseudo_manquant;
|
|
|
39 |
if ($_POST['type_inscription']=='1' && !$_POST['ecole'])
|
|
|
40 |
$erreurs[] = $ecole_manquant;
|
|
|
41 |
if (!$_POST['nom'])
|
|
|
42 |
$erreurs[] = $nom_manquant;
|
|
|
43 |
if (!$_POST['prenom'])
|
|
|
44 |
$erreurs[] = $prenom_manquant;
|
|
|
45 |
if (!$_POST['adresse'])
|
|
|
46 |
$erreurs[] = $adresse_manquant;
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
// On ne verifie la presence du code postal uniquement pour la france //FONCTIONNEMENT_TESTE_ET_OK
|
|
|
50 |
if (($_POST['pays']) && ($_POST['pays']=='fr')) {
|
|
|
51 |
if (!$_POST['code_postal']) {
|
|
|
52 |
$erreurs[] = $cp_manquant;
|
|
|
53 |
}
|
|
|
54 |
else { // On padde a gauche avec des zero
|
|
|
55 |
$_POST['code_postal']=str_pad($_POST['code_postal'], 5, "0", STR_PAD_LEFT);
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
if (!$_POST['ville'])
|
|
|
60 |
$erreurs[] = $ville_manquant;
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
if (!$_POST['mail'])
|
|
|
64 |
$erreurs[] = $mail_manquant;
|
|
|
65 |
if (!$_POST['mail_confirm'])
|
|
|
66 |
$erreurs[] = $mail_confirm_manquant;
|
|
|
67 |
if (!$_POST['pays'])
|
|
|
68 |
$erreurs[] = $pays_confirm_manquant;
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
$visible = (isset($_POST['nom_prenom_visible']))? '1':'0' ;
|
|
|
72 |
$newslettre = (isset($_POST['newsletter']))? '1':'0' ;
|
|
|
73 |
$type_inscrip = (isset($_POST['type_inscription']))? $_POST['type_inscription']: "NULL" ;
|
|
|
74 |
$niveau = (isset($_POST['niveau']))? $_POST['niveau']: "NULL" ;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
$choixCommune = false;
|
|
|
78 |
|
|
|
79 |
/**** L'inscription va avoir lieu, dernieres verifs aux niveau de la base ****/
|
|
|
80 |
if (isset($_POST['valid']) && sizeof($erreurs)==0 && !isset($_POST['commune'])) {
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
//Verification du pseudo
|
|
|
85 |
$requete_pseudo = mysql_query("select PARTICIPANT_PSEUDO from PARTICIPANT where PARTICIPANT_PSEUDO LIKE '".addSlashes($_POST['pseudo'])."'");
|
|
|
86 |
if (mysql_num_rows($requete_pseudo)>0)
|
|
|
87 |
$erreurs[] = $pseudo_existant;
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
//S'il n'y a qu'une commune correspondant au code postal choisi
|
|
|
93 |
if (isset($_POST['valid']) && sizeof($erreurs)==0 ) {
|
|
|
94 |
|
|
|
95 |
//Generation du mot de passe
|
|
|
96 |
$alphabet = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
|
|
|
97 |
for ($i=0; $i<3; $i++) {
|
|
|
98 |
$motdepasse .= $alphabet[rand(0,sizeof($alphabet))];
|
|
|
99 |
}
|
|
|
100 |
for ($i=0; $i<3; $i++) {
|
|
|
101 |
$motdepasse .= rand(0,9);
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
//Construction de la requete d'inscription
|
|
|
107 |
$requete_inscript = "insert into PARTICIPANT (COMMUNE_ID, NIVEAU_ID, TYPE_INSCRIPTION_ID, PARTICIPANT_PSEUDO, ".
|
|
|
108 |
"PARTICIPANT_ECOLE, PARTICIPANT_NOM, PARTICIPANT_PRENOM, PARTICIPANT_ADRESSE, PARTICIPANT_CODE_POSTAL,".
|
|
|
109 |
"PARTICIPANT_VILLE, PARTICIPANT_EMAIL, PARTICIPANT_ADULTE, PARTICIPANT_EN_ATTENTE, PARTICIPANT_MOTDEPASSE,".
|
|
|
110 |
"PARTICIPANT_NOM_PRENOM_VISIBLE, PARTICIPANT_RECEVOIR_NEWSLETTER, PAYS_ID, DEPARTEMENT_ID,".
|
|
|
111 |
"PARTICIPANT_DATE_INSCRIPTION) ".
|
|
|
112 |
"values ('$commune', ".$niveau.", ".$type_inscrip.", '".addSlashes($_POST['pseudo']).
|
|
|
113 |
"', '".addSlashes($_POST['ecole'])."', "."'".addSlashes($_POST['nom'])."', '".addSlashes($_POST['prenom']).
|
|
|
114 |
"', '".addSlashes($_POST['adresse'])."', '".addSlashes($_POST['code_postal'])."', '".addSlashes($_POST['ville']).
|
|
|
115 |
"', "."'".$_POST['mail']."', ".PARTICIPANT_EST_ADULTE.", 1, '".$motdepasse."', ".$visible.", ".$newslettre.", '".
|
|
|
116 |
$_POST['pays']."', '".substr($_POST['code_postal'],0,2)."', now())";
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
//faut il inscrire le mail à la newsletter
|
|
|
120 |
if (isset($_POST['newsletter'])) {
|
|
|
121 |
mail('actu-subscribe@obs-saisons.fr',"Inscription actualites de l'Observatoire des Saisons",
|
|
|
122 |
'inscription',"From: ".$_POST['mail']);
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
if (!mysql_query($requete_inscript))
|
|
|
126 |
$erreurs[] = "La requete a echoue : ".mysql_error();
|
|
|
127 |
else
|
|
|
128 |
$inscriptionOk = true;
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
if (!(isset($_POST['valid']) && sizeof($erreurs)==0) || $choixCommune) {
|
|
|
134 |
|
|
|
135 |
/***** Demande d'inscription au site *****/
|
|
|
136 |
|
|
|
137 |
$requete_types = mysql_query("select TYPE_INSCRIPTION_ID, TYPE_INSCRIPTION_NOM from TYPE_INSCRIPTION");
|
|
|
138 |
|
|
|
139 |
$requete_niveaux = mysql_query("select NIVEAU_ID, NIVEAU_NOM from NIVEAU");
|
|
|
140 |
|
|
|
141 |
//Affichage des eventuelles erreurs
|
|
|
142 |
if (sizeof($erreurs)>0) {
|
|
|
143 |
echo "<div class='erreurs'>";
|
|
|
144 |
foreach ($erreurs as $err)
|
|
|
145 |
echo $err."<br>";
|
|
|
146 |
echo "</div>";
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
//Selon le type d'inscription, il faudra afficher ou pas certains champs
|
|
|
150 |
function disable($type_inscr) {
|
|
|
151 |
if ($type_inscr && $type_inscr!='1')
|
|
|
152 |
echo " class=\"disabled\" disabled=\"true\"";
|
|
|
153 |
}
|
|
|
154 |
?>
|
|
|
155 |
<br>
|
|
|
156 |
<form name="form_inscription" method="post" action="#">
|
|
|
157 |
<table border="0">
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
<?php
|
|
|
161 |
if (!PARTICIPANT_EST_ADULTE) { ?>
|
|
|
162 |
<tr>
|
|
|
163 |
<td>Je m'inscris avec</td>
|
|
|
164 |
<td><select name="type_inscription" onchange="changementType()">
|
|
|
165 |
<?php
|
|
|
166 |
while ($type = mysql_fetch_row($requete_types)) {
|
|
|
167 |
echo "<option value='".$type[0]."'";
|
|
|
168 |
if ($_POST['type_inscription']==$type[0])
|
|
|
169 |
echo " selected";
|
|
|
170 |
echo ">".$type[1];
|
|
|
171 |
}
|
|
|
172 |
?>
|
|
|
173 |
</select></td>
|
|
|
174 |
</tr>
|
|
|
175 |
<tr>
|
|
|
176 |
<td>Notre pseudo est </td>
|
|
|
177 |
<td><input type="text" name="pseudo" value="<?= $_POST['pseudo'] ?>"></td>
|
|
|
178 |
</tr>
|
|
|
179 |
<tr>
|
|
|
180 |
<td>Le nom de mon école est </td>
|
|
|
181 |
<td><input type="text" name="ecole" value="<?= $_POST['ecole'] ?>" <?= disable($_POST['type_inscription']) ?>></td>
|
|
|
182 |
</tr>
|
|
|
183 |
<tr>
|
|
|
184 |
<td>Le niveau de ma classe est</td>
|
|
|
185 |
<td><select name="niveau" <?= disable($_POST['type_inscription']) ?>>
|
|
|
186 |
<?php
|
|
|
187 |
while ($niveau = mysql_fetch_row($requete_niveaux)) {
|
|
|
188 |
echo "<option value='".$niveau[0]."'";
|
|
|
189 |
if ($_POST['niveau']==$niveau[0])
|
|
|
190 |
echo " selected";
|
|
|
191 |
echo ">".$niveau[1];
|
|
|
192 |
}
|
|
|
193 |
?>
|
|
|
194 |
</select></td>
|
|
|
195 |
</tr>
|
|
|
196 |
<tr>
|
|
|
197 |
<td>Le nom du responsable est</td>
|
|
|
198 |
<td><input type="text" name="nom" value="<?= $_POST['nom'] ?>"></td>
|
|
|
199 |
</tr>
|
|
|
200 |
<tr>
|
|
|
201 |
<td>Le prénom du responsable est</td>
|
|
|
202 |
<td><input type="text" name="prenom" value="<?= $_POST['prenom'] ?>"></td>
|
|
|
203 |
</tr>
|
|
|
204 |
<tr>
|
|
|
205 |
<?php } else { ?>
|
|
|
206 |
<tr>
|
|
|
207 |
<td style="text-align:right;">Identifiant (pseudo) : </td>
|
|
|
208 |
<td><input type="text" name="pseudo" value="<?= $_POST['pseudo'] ?>"></td>
|
|
|
209 |
</tr>
|
|
|
210 |
<tr>
|
|
|
211 |
<td style="text-align:right;">Nom : </td>
|
|
|
212 |
<td><input type="text" name="nom" value="<?= $_POST['nom'] ?>"></td>
|
|
|
213 |
</tr>
|
|
|
214 |
<tr>
|
|
|
215 |
<td style="text-align:right;">Prénom : </td>
|
|
|
216 |
<td><input type="text" name="prenom" value="<?= $_POST['prenom'] ?>"></td>
|
|
|
217 |
</tr>
|
|
|
218 |
<?php } ?>
|
|
|
219 |
|
|
|
220 |
<tr>
|
|
|
221 |
<td style="text-align:right;">Adresse postale : </td>
|
|
|
222 |
<td><input type="text" name="adresse" value="<?= $_POST['adresse'] ?>"></td>
|
|
|
223 |
</tr>
|
|
|
224 |
<tr>
|
|
|
225 |
<td style="text-align:right;">Code postal : </td>
|
|
|
226 |
<td><input type="text" name="code_postal" value="<?= $_POST['code_postal'] ?>"></td>
|
|
|
227 |
</tr>
|
|
|
228 |
<tr>
|
|
|
229 |
<td style="text-align:right;">Ville : </td>
|
|
|
230 |
<td><input type="text" name="ville" value="<?= $_POST['ville'] ?>"></td>
|
|
|
231 |
</tr>
|
|
|
232 |
|
|
|
233 |
<tr>
|
|
|
234 |
<td style="text-align:right;">Pays : </td>
|
|
|
235 |
<td>
|
|
|
236 |
<select name="pays">
|
|
|
237 |
<?php
|
|
|
238 |
$requete_pays = mysql_query("SELECT CP_ID_Pays, CP_Intitule_pays FROM carto_PAYS WHERE CP_Langue_intitule='fr'");
|
|
|
239 |
while ($val_pays = mysql_fetch_assoc($requete_pays)) {
|
|
|
240 |
echo '<option value="'.$val_pays['CP_ID_Pays'].'" ';
|
|
|
241 |
if ($val_pays['CP_ID_Pays']=='fr') echo 'selected="selected" ';
|
|
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
|
245 |
echo '>'.$val_pays['CP_Intitule_pays'].'</option>'."\n";
|
|
|
246 |
}
|
|
|
247 |
?>
|
|
|
248 |
</select>
|
|
|
249 |
</td>
|
|
|
250 |
</tr>
|
|
|
251 |
|
|
|
252 |
<tr>
|
|
|
253 |
<td style="text-align:right;">Adresse e-mail : </td>
|
|
|
254 |
<td><input type="text" name="mail" value="<?= $_POST['mail'] ?>"></td>
|
|
|
255 |
</tr>
|
|
|
256 |
<tr>
|
|
|
257 |
<td style="text-align:right;">Confirmation de l'adresse e-mail : </td>
|
|
|
258 |
<td><input type="text" name="mail_confirm" value="<?= $_POST['mail_confirm'] ?>"></td>
|
|
|
259 |
</tr>
|
|
|
260 |
|
|
|
261 |
<tr>
|
|
|
262 |
<td colspan="2"><label><input type="checkbox" name="nom_prenom_visible" id="nom_prenom_visible" value="1"
|
|
|
263 |
<?php if ($visible) echo 'checked="checked" ';?> />
|
|
|
264 |
Je souhaite voir mon nom et prénom apparaitre sur la carte plutôt que mon pseudo</label></td>
|
|
|
265 |
</tr>
|
|
|
266 |
|
|
|
267 |
<tr>
|
|
|
268 |
<td colspan="2"><label><input type="checkbox" name="newsletter" id="newsletter" value="1"
|
|
|
269 |
<?php /*if ($newslettre)*/ echo 'checked="checked" ';?> />
|
|
|
270 |
Je souhaite être abonné à la lettre d'actualité</label></td>
|
|
|
271 |
</tr>
|
|
|
272 |
|
|
|
273 |
<tr>
|
|
|
274 |
<td colspan="2" style="text-align:center;"><input type="submit" class="submit" name="valid" value="Mise à jour"></td>
|
|
|
275 |
</tr>
|
|
|
276 |
</table>
|
|
|
277 |
</form>
|
|
|
278 |
<?php } ?>
|