0
I am making a registration that cannot have users with the same name/nick registered. To validate whether or not PHP is used, I would like to know how to print a p with a message on the screen if there is already a user with that registered name. I tried to do it like this, but it doesn’t work
if(is_null($id)){
$sql = "INSERT INTO usuario (nick, email, senha) VALUES ('$nick' , '$email' ,'$senha')";
$q = mysqli_query($con,$sql);
$url = 'aux.php';
echo'<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
else{
?>
<script type='text/javascript'>
var uso = document.getElementById('emUso');
uso.innerHTML = 'Este nick já está em uso!'
</script>
<?php
}
For these reasons php has a bad reputation. To solve your problem, look for Ajax requests in javascript. You can make a query in the database to see if this nick name already exists every time you change the input value, if it returns false, generate an error msg or something like that. The way you’re doing besides being wrong, it’s bad practice.
– LucaoA
uses Ajaxassociated with jquery bind
– zwitterion
Hmm, okay. Thank you very much!
– paloma