1
I was testing the registrations of the site I did, and I noticed that I managed to register the same username 2 times, even having declared "UNIQUE" in the table.
And another thing, I also noticed that although I have left the required fields, if someone enters space, the record is successfully done. How to stop something like this from happening?
Below is the entry 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");
?>
Poxa Raphael, thank you so much for your help, I will test still on the check. On the removal of spaces, I am validating all the data directly by php, and there I tried some codes and it didn’t work as I wanted.
– lua kim