1
Hello, In this code I would like to display two existing data message on the server being the matricula (which already works perfectly) and e-mail. I’ve tried some ways to insert these two messages, but without success... follow the code:
<?php
include_once 'conexao.php';
$session_start = session_start();
$nome = filter_input(INPUT_POST, 'inputNome', FILTER_SANITIZE_SPECIAL_CHARS);
$email = filter_input(INPUT_POST, 'inputEmail', FILTER_VALIDATE_EMAIL);
$telefone = filter_input(INPUT_POST, 'inputTel', FILTER_SANITIZE_NUMBER_INT);
$matricula = filter_input(INPUT_POST, 'inputMatricula', FILTER_SANITIZE_NUMBER_INT);
$querySelect = $link->query("select * from tb_clientes");
$array_emails = [];
$array_matriculas = [];
while ($matriculas = $querySelect->fetch_assoc()):
$matricula_existentes = $matriculas['matricula'];
array_push($array_matriculas, $matricula_existentes);
endwhile;
if (in_array($matricula,$array_matriculas)):
$_SESSION['msg'] = "<p class='center red-text'>" . 'Já existe um servidor cadastrado com essa matrícula' . "</p>";
header("Location:../");
else:
$queryInsert = $link->query("insert into tb_clientes values(default,'$nome','$email','$telefone','$matricula')");
$affected_rows = mysqli_affected_rows ($link);
if ($affected_rows > 0):
$_SESSION['msg'] = "<p class='center green-text'>".'Cadastro efetuado com sucesso!'."<br>";
header("Location:../");
endif;
endif;
What mistake you get?
– gustavox
do not understand well, you want a return msg if the email already exists?
– Wees Smith
Exactly Wees
– Oggi Mrm
gustavox, no error in the code, I just want a second return message if the email exists
– Oggi Mrm