I need to do a validation in my mysql database if the email they are trying to register already exists in the database, so I have the following code in the web service:
if ($_SERVER["REQUEST_METHOD"] == "POST") {
require 'connect.php';
inReg();
}
function inReg() {
global $connect;
$email = $_POST["email"];
$sql = "SELECT * FROM usuario WHERE email like '$email'";
$resultado = mysqli_query($connect, $sql);
if (mysqli_num_rows($resultado) <= 0) {
$nomepasta = $_REQUEST['email'];
$UploadFotos = "../../../webapps/ROOT/imagens/".$nomepasta;
//$UploadFotos = "UploadFotos/".$nomepasta;
if (!file_exists($UploadFotos)) {
if (!mkdir($UploadFotos));
}
global $connect;
$nome = $_POST["nome"];
$senha = $_POST["senha"];
$codificada = md5($senha);
$email = $_POST["email"];
$telefone = $_POST["telefone"];
$query = " Insert into usuario(nome, senha, email, telefone) values ('$nome','$codificada','$email','$telefone')";
mysqli_query($connect, $query) or die(mysqli_error($connect));
mysqli_close($connect);
} else {
? ? ? ? ? ? ? ? ? ? ? ? ? ?
}
} ?>
I do not know what to return if I fall into the first condition (there is an email address). I have to show in the android application that this email has already been registered.