diff --git a/htdocs/adherents/public/new.php b/htdocs/adherents/public/new.php
index 6ef68db9216..837a217c681 100644
--- a/htdocs/adherents/public/new.php
+++ b/htdocs/adherents/public/new.php
@@ -27,41 +27,60 @@ require("../../paiement.class.php");
$db = new Db();
-llxHeader();
+$errmsg='';
+$num=0;
if ($HTTP_POST_VARS["action"] == 'add')
{
-
- $adh = new Adherent($db);
- $adh->statut = -1;
- $adh->prenom = $prenom;
- $adh->nom = $nom;
- $adh->societe = $societe;
- $adh->adresse = $adresse;
- $adh->cp = $cp;
- $adh->ville = $ville;
- $adh->email = $email;
- $adh->login = $login;
- $adh->pass = $pass;
- $adh->note = $note;
- $adh->pays = $pays;
- $adh->typeid = $type;
- $adh->commentaire = $HTTP_POST_VARS["comment"];
- $adh->morphy = $HTTP_POST_VARS["morphy"];
+ // test si le login existe deja
+ $sql = "SELECT login FROM llx_adherent WHERE login='$login';";
+ $result = $db->query($sql);
+ if ($result) {
+ $num = $db->num_rows();
+ }
- if ($adh->create($user->id) )
- {
- if ($cotisation > 0)
- {
- $adh->cotisation(mktime(12, 0 , 0, $remonth, $reday, $reyear), $cotisation);
- }
- // Envoi d'un Email de confirmation au nouvel adherent
- $mesg="Merci de votre inscription. Votre adhesion devrait etre rapidement validee.\nVoici le rappel des coordonnees que vous avez rentrees (toute information erronee entrainera la non validation de votre inscription) :\nPrenom : $prenom\nNom : $nom\nSociete = $societe\nAdresse = $adresse\nCode Postal : $cp\nVille : $ville\nPays : $pays\nEmail : $email\nLogin : $login\nPassword : $pass\nNote : $note\nType : $type\n\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\nhttp://$SERVER_NAME/adherents/private/edit.php\n\n";
- mail($email,"Votre adhesion sur http://$SERVER_NAME/",$mesg);
- Header("Location: new.php?action=added");
+ if (isset($email) && $email != '' && ereg('@',$email) && !$num){
+ // email a peu pres correct et le login n'existe pas
+ $adh = new Adherent($db);
+ $adh->statut = -1;
+ $adh->prenom = $prenom;
+ $adh->nom = $nom;
+ $adh->societe = $societe;
+ $adh->adresse = $adresse;
+ $adh->cp = $cp;
+ $adh->ville = $ville;
+ $adh->email = $email;
+ $adh->login = $login;
+ $adh->pass = $pass;
+ $adh->note = $note;
+ $adh->pays = $pays;
+ $adh->typeid = $type;
+ $adh->commentaire = $HTTP_POST_VARS["comment"];
+ $adh->morphy = $HTTP_POST_VARS["morphy"];
+
+ if ($adh->create($user->id) )
+ {
+ if ($cotisation > 0)
+ {
+ $adh->cotisation(mktime(12, 0 , 0, $remonth, $reday, $reyear), $cotisation);
+ }
+ // Envoi d'un Email de confirmation au nouvel adherent
+ $mesg="Merci de votre inscription. Votre adhesion devrait etre rapidement validee.\nVoici le rappel des coordonnees que vous avez rentrees (toute information erronee entrainera la non validation de votre inscription) :\n\nPrenom : $prenom\nNom : $nom\nSociete = $societe\nAdresse = $adresse\nCode Postal : $cp\nVille : $ville\nPays : $pays\nEmail : $email\nLogin : $login\nPassword : $pass\nNote : $note\n\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\nhttp://$SERVER_NAME/adherents/private/edit.php\n\n";
+ mail($email,"Votre adhesion sur http://$SERVER_NAME/",$mesg);
+ Header("Location: new.php?action=added");
+ }
+ }else{
+ if ($num ==0){
+ $errmsg .="Login deja utilise. Veuillez en changer
\n";
}
+ if (isset($email) && $email != '' && ereg('@',$email)){
+ $errmsg .="Adresse Email invalide
\n";
+ }
+ }
}
+llxHeader();
+
/* ************************************************************************** */
/* */
@@ -70,22 +89,13 @@ if ($HTTP_POST_VARS["action"] == 'add')
/* ************************************************************************** */
-$sql = "SELECT s.nom,s.idp, f.amount, f.total, f.facnumber";
-$sql .= " FROM societe as s, llx_facture as f WHERE f.fk_soc = s.idp";
-$sql .= " AND f.rowid = $facid";
-
if (isset($action) && $action== 'added'){
print "Nouvel Adhérent ajouté. En attente de validation
\n";
}
-$result = $db->query($sql);
-if ($result) {
- $num = $db->num_rows();
- if ($num) {
- $obj = $db->fetch_object( 0);
-
- $total = $obj->total;
- }
+if (isset($errmsg) && $errmsg != ''){
+ print "$errmsg
\n";
}
+
print_titre("Nouvel adhérent");
print "Les login et password vous serviront a editer vos coordonnees ulterieurement
\n";
print "