0
next. I am doing a validation with angular and php, for when a user is registering, be checked if such user and password already exist and is not registered again. And I need php to return some information to angular so that a message can be displayed if there is a user with the same data.
my php:
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
include_once("conPDO.php");
$pdo = conectar();
$data = file_get_contents("php://input");
$data = json_decode($data);
$nome = $data->nome;
$email = $data->email;
$senha = $data->senha;
$idCep = $data->idCep;
$tipoUsuario = "C";
$verificaUsuario=$pdo->prepare("SELECT * FROM usuarios WHERE nome=:nome AND email=:email");
$verificaUsuario->bindValue("nome", $nome);
$verificaUsuario->bindValue("email", $email);
$verificaUsuario->execute();
$quant = $verificaUsuario->rowCount();
if($quant != 1){
$insereUsuario=$pdo->prepare("INSERT INTO usuarios (idUsuario, idCep, tipoUsuario, nome, email, senha) VALUES (?, ?, ?, ?, ?, ?)");
$insereUsuario->bindValue(1, NULL);
$insereUsuario->bindValue(2, $idCep);
$insereUsuario->bindValue(3, $tipoUsuario);
$insereUsuario->bindValue(4, $nome);
$insereUsuario->bindValue(5, $email);
$insereUsuario->bindValue(6, $senha);
$insereUsuario->execute();
}else{
O que colocar aqui?
}
?>
But beyond that, I need some information to go back to the angle so I can display this message on the screen, you know?
– GustavoSevero
I understand, sorry, I thought you wanted to return to the
PHP
, I will look to know here also I do update in my post.– Guilherme SpinXO
@Gustavosevero it is interesting that you add this information also in the question, to avoid wrong answers. Reading quickly, I imagined a solution similar to William’s.
– user28595