I need a bit of help with my registration page: when I try to put an username and a pwd I can't understand why it doesn't work and I don't know how to show the error in any way. Work everything but it can't insert the data in the database, and I'm sure that the connection to the database works!
I've also tried to print the $query and it's right. I think that the error is in $inseriscidati but I don't now what can be the problem
Following the code:
<?php
$mex = "";
$database = "users";
$userArray = "SELECT 'username' FROM $database";
if(isset($_POST['submit'])){
$user = $_POST['user'];
$pass = $_POST['pass'];
$passconf = $_POST['passconf'];
$username = mysqli_real_escape_string($connessione,$user);
$password = mysqli_real_escape_string($connessione,$pass);
$passwordConf = mysqli_real_escape_string($connessione,$passconf);
if($username != "" && $password != "" && $passwordConf != ""){
if($password == $passwordConf){
if($user != $userArray){
$passwordCrypt = crypt($password, '$6$rounds=5000$usesomesillystringforsalt$');
$query = "INSERT INTO `users` (`username`,`passwor`) VALUES (`$username`, `$passwordCrypt`)";
$inseriscidati = mysqli_query($connessione,$query);
if(!$inseriscidati){
$mex = "<p style='color: red;'>A causa di un errore non è stato possibile caricare i dati. Riprova più tardi!</p>";
mysqli_error($connessione);
echo "\n Password criptata: ".$passwordCrypt;
echo "\n Query: ".$query;
header("Location: $currentpage?DatiNonInseriti");
}else{
header("Location : $currentpage?DatiInseritiCorrettamente");
$mex = "<p style='color: green;'>I dati inseriti sono stati caricati correttamente!</p>";
}
}else $mex = "<p style='color: red;'>Username non disponibile</p>";
}else $mex = "<p style='color: red;'>Le password non corrispondono</p>";
}else $mex = "<p style='color: red;'>Compilare tutti i campi</p>";
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<?php if($mex != "") echo $mex; ?>
<input type="text" placeholder="Inserire Username" name="user" >
<input type="password" placeholder="Crea Password" name="pass" minlength="8" maxlength="20">
<input type="password" placeholder="Conferma Password" name="passconf"minlength="8" maxlength="20">
<input type="submit" name="submit">
</form>```