Create a REST API with PDO

Today I would like to create an API for my Ionic application to run my registration form.
However I doubt about my PHP script, I think it is not functional.

$query = $db->prepare("INSERT INTO user(nom, prenom, pseudo, email, mdp) VALUES(:nom, :prenom, :pseudo, :email, :mdp)");
    'nom' => $nom,
    'prenom' => $prenom,
    'pseudo' => $pseudo,
    'email' => $email,
    'mdp' => password_hash($mdp, PASSWORD_BCRYPT)

And here’s how I use it:

    postData(dataToSend) {
        return, dataToSend, {headers: new HttpHeaders({'content-Type': 'application/json'})});
    postData() {
        const dataToSend = {
            nom: this.nom,
            prenom: this.prenom,
            pseudo: this.pseudo,
            mdp: this.mdp
        this.inscription.postData(dataToSend).subscribe((dataReturnFromService) => {
            this.dataFromService = JSON.stringify(dataReturnFromService);

This code does not work, no data enters my database. Do you have an idea?

I still have the same problem since all this time … :frowning:

I changed my code and currently I have this one but the data still does not fit in the database …

    $type = $_POST['type'];
    $prenom = $_POST['prenom'];
    $nom = $_POST['prenom'];
    $pseudo = $_POST['pseudo'];
    $email = $_POST['email'];
    $mdp = $_POST['mdp'];
    $confirmMdp = $_POST['confirmMdp'];
    $query=$db->prepare('SELECT * FROM user WHERE email = :email');
        $query->bindValue(':email',$_POST['email'], PDO::PARAM_STR);
    if ($data['email'] == ($_POST['email'])) // Acces pas OK !
       echo 'Compte déjà existant';
    } else if($_POST['mdp'] == $_POST['mdp2']) // Acces OK !
        echo 'Success';
        $query=$db->prepare('INSERT INTO user(type, prenom, nom, pseudo, email, mdp) VALUES(:type, :prenom, :nom, :pseudo, :email, :mdp)');
                                     'type' => $type,
                                     'prenom' => $prenom,
                                     'nom' => PASSWORD_HASH($nom, PASSWORD_BCRYPT),
                                     'pseudo' => $pseudo,
                                     'email' => $email,
                                     'mdp' => $mdp
                                     } else {
                                         echo 'failled';
    register() {
        if (this.mdp === this.confirmMdp) {
            // tslint:disable-next-line:max-line-length
  '', {
                type: this.type,
                prenom: this.prenom,
                nom: this.nom,
                pseudo: this.pseudo,
                mdp: this.mdp

What’s wrong with my code?
I need your help