I was testing the site registrations I made, and I noticed that I was able to register the same username twice, even though I declared "UNIQUE" in the table.
And another thing, I also noticed that although I left the fields obligatory, in case someone type space, the registration is done successfully. How do I prevent something like this from happening?
Below is the insertion code in the database:
<?php
// captura dos dados digitados no formulário //
$nome=$_POST ['nome'];
$sobrenome=$_POST ['sobrenome'];
$username=$_POST ['username'];
$email=$_POST ['email'];
$senha=$_POST ['senha'];
$telefone=$_POST ['telefone'];
$sql = mysql_query("INSERT INTO cadastro (nome,sobrenome,username,email,senha,telefone) VALUES ('$nome', '$sobrenome','$username','$email','$senha','$telefone')") or die(mysql_error());
$resultado = mysql_query ($sql);
header ("Location:../usuario/index.php");
?>