51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
|
<?php
|
||
|
|
||
|
require_once 'connexionbdd.php';
|
||
|
|
||
|
if(!isset($_POST['first_name'], $_POST['last_name'], $_POST['pseudo'], $_POST['password'], $_POST['repassword']))
|
||
|
{
|
||
|
$reponse = "n";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$firstname = $_POST['first_name'];
|
||
|
$lastname = $_POST['last_name'];
|
||
|
$pseudo = $_POST['pseudo'];
|
||
|
$pass = $_POST['password'];
|
||
|
$repass = $_POST['repassword'];
|
||
|
$pass = md5($pass);
|
||
|
$repass = md5($repass);
|
||
|
if($pass == $repass)
|
||
|
{
|
||
|
$bdd = connexionBD();
|
||
|
//$requete = $bdd->prepare("SELECT COUNT(pseudo) AS check FROM login WHERE pseudo = :pseudo LIMIT 1");
|
||
|
//$requete->bindValue(":pseudo", $pseudo);
|
||
|
//$requete->execute();
|
||
|
//$output = $requete->fetch();
|
||
|
|
||
|
$requete = $bdd->query("SELECT pseudo FROM login WHERE pseudo = '$pseudo'");
|
||
|
$count = $requete->rowCount();
|
||
|
|
||
|
if($count != 1)
|
||
|
{
|
||
|
$requete = $bdd->prepare("INSERT INTO login (pseudo, prenom, nom, mdp) VALUES (:pseudo, :prenom, :nom, :mdp)");
|
||
|
$requete->bindParam(":pseudo", $pseudo);
|
||
|
$requete->bindParam(":prenom", $firstname);
|
||
|
$requete->bindParam(":nom", $lastname);
|
||
|
$requete->bindParam(":mdp", $pass);
|
||
|
$requete->execute();
|
||
|
$reponse = "v";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$reponse = "i";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$reponse = "u";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
echo json_encode($reponse);
|