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
| if($fp = fopen($fichier,"r")){
//on ne lit pas la première ligne (en-tête)
$ligne = fgets($fp,4096);
/* extraction d'une ligne */
while($ligne = fgets($fp)){
$tableau = explode(';',$ligne);
for($i=0;$i<1;$i++){
//Vérification que la personne n'est pas déjà présente dans la table
$nommin1 = strtolower($tableau[4]);
$prenommin1 = strtolower($tableau[5]);
$verification = mysql_query('SELECT * FROM votants WHERE nom_votant = "'.$nommin1.'" AND prenom_votant = "'.$prenommin1.'"');
$resultat = mysql_num_rows($verification);
if($tableau[4]!='' && $tableau[5]!='' && $resultat == 0){
$parent1 = mysql_query('INSERT INTO votants (id_votant,login_votant,mdp_votant,nom_votant,prenom_votant,nom_eleve,prenom_eleve,classe_eleve,etat_votant)
VALUES ("","","","'.$tableau[4].'","'.$tableau[5].'","'.$tableau[0].'","'.$tableau[1].'","'.$tableau[2].'","")');
if($parent1){
echo 'requête '.$tableau[4].$tableau[5].' OK.<br />';
}
}
//Vérification que la personne n'est pas déjà présente dans la table
$nommin2 = strtolower($tableau[7]);
$prenommin2 = strtolower($tableau[8]);
$verification2 = mysql_query('SELECT * FROM votants WHERE nom_votant = "'.$nommin2.'" AND prenom_votant = "'.$prenommin2.'"');
$resultat2 = mysql_num_rows($verification2);
if($tableau[7]!='' && $tableau[8]!='' && $resultat2 == 0){
$parent2 = mysql_query('INSERT INTO votants (id_votant,login_votant,mdp_votant,nom_votant,prenom_votant,nom_eleve,prenom_eleve,classe_eleve,etat_votant)
VALUES ("","","","'.$tableau[7].'","'.$tableau[8].'","'.$tableau[0].'","'.$tableau[1].'","'.$tableau[2].'","")');
if($parent2){
echo 'requête '.$tableau[7].$tableau[8].' OK.<br />';
}
}
}
}
echo '<span style="color: #009900;font-weight: bold;">Upload effectué avec succès !</span><br />';
} |
Partager