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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
| <?php
class inscription
{
//Connection à la base, fichier config
private $host_bd;
private $indentifiant_bd;
private $pass_bd;
private $nom_bd;
//Connection à la base Construct
private $SQLconnect;
private $etat_connection;
private $bdReady;
//Incription membre
private $pseudo, $mdp, $mdp2, $nom, $prenom, $adresse, $cp, $ville, $tel1, $tel2, $mail;
//Message exterieur classe
public $msg;
function __construct()
{
//Fichier de config base
require_once("base.php");
//Vérifie et effectue la connection
if($this->SQLconnect = @mysql_connect($this->host_bd, $this->indentifiant_bd, $this->pass_bd))
{
$this->etat_connection = 1;
if(mysql_select_db($this->nom_bd))
{
$this->bdReady = 1;
}
else
{
die('Erreur de connection à la base.');
}
}
else
{
die('Erreur de connection au serveur SQL.');
}
}
function verification($pseudo, $mdp, $mdp2, $nom, $prenom, $adresse, $cp, $ville, $tel1, $tel2, $mail)
{
//TEST si variables vides
if($pseudo!="" && $mdp!="" && $mdp2!="" && $nom!="" && $prenom!="" && $adresse!="" &&
$cp!="" && $ville!="" && $mail!="")
{
//Verification pseudo
$req = mysql_query("SELECT COUNT(*) FROM joueur WHERE pseudo = '".strtolower($pseudo)."' ");
$sql = mysql_fetch_row($req);
if($sql[0] == 0)
{
//Verification mail
$syntaxe_mail='#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#';
if(preg_match($syntaxe_mail,$mail))
{
//Verification mail utilisé
$verifmail = mysql_query("SELECT COUNT(*) FROM joueur_info WHERE mail = '".$mail."' ");
$verifmail2 = mysql_fetch_row($verifmail);
if($verifmail2[0] == 0)
{
//Verification MDP
if($mdp == $mdp2)
{
$this->ajout($pseudo, $mdp, $mdp2, $nom, $prenom, $adresse, $cp, $ville, $tel1, $tel2, $mail);
}
else $this->msg="Retapez le même mot de passe!<br>";
}
else $this->msg="Mail déjà utilisé!<br>";
}
else $this->msg="Format email invalide!<br>";
}
else $this->msg="Pseudo déjà utilise!<br>";
}
else $this->msg="Veuillez remplir tous les champs obligatoires svp.<br>";
}
private function ajout($pseudo, $mdp, $mdp2, $nom, $prenom, $adresse, $cp, $ville, $tel1, $tel2, $mail)
{
//Si un parrain existe
if (isset ($_COOKIE['parrain']))
{
$id_parrain = intval($_COOKIE['parrain']);
}
//Insertion table joueur
$sql1 = mysql_query("INSERT INTO joueur VALUES ('','".strtolower($pseudo)."','".$pseudo."',
'".$mdp."','','10','','".$id_parrain."')")
or die("Probleme! Contactez l'équipe admin@c-cado.fr");
//Variable session pour l'id
$id_joueur=mysql_insert_id();
$_SESSION['id_joueur'] = $id_joueur ;
//Insertion table joueur_infos
$sql2 = mysql_query("INSERT INTO joueur_info VALUES ('','".$nom."','".$prenom."','".$adresse."','".$cp."',
'".$ville."','".$tel1."','".$tel2."','".$mail."')")
or die("Probleme! Contactez l'équipe admin@c-cado.fr");
//Insertion table parrainage
if (isset ($id_parrain))
{
mysql_query ("INSERT INTO parrainage VALUES ('".$id_parrain."','".$id_joueur."')")
or die ("<b><p align=center><font color=red>Probleme! Contactez l\'équipe admin@c-cado.fr</font></p></b>");
}
//Retour index
header("location:index.php");
}
}
?> |
Partager