- Home
- Categorie
- Coding e Sistemistica
- PHP
- problema registrazione utenti
-
problema registrazione utenti
effettuo la registrazione con un username già esistente e mi registra nuovamente...
<?php
session_start();
?>
<?
include "config.php";
// inizializza sempre le variabili che usi in uno script
$username="";
$psw="";
$repsw="";
// assegna i valori POSTati a queste variabili hashando la password
$username=$_POST['username'];
$psw=md5($_POST['password']);
$repsw=md5($_POST['repassword']);
$ver = "SELECT * FROM messaggi WHERE username= '$username'";
$tabver = @mysql_query ($ver) or die (mysql_error());
$veruser = mysql_num_rows ($tabver);
if ($username=='' || $psw=='' || $repsw=='')
{
echo '<br>Compila correttamente tutti i campi';
}
else if ($psw !== $repsw)
{
echo "<br>Controllare la password digitata.";
}
else if ($veruser !== 0)
{
echo "<br>L'username richiesto risulta già registrato";
}
else if (eregi("[:,;èéçòà °@#ù§*+^ì'<>?!£$%&/=()]", $username))
{
echo "<br>Il nick contiene caratteri non validi.";
}
else
{$inserimento=mysql_query( "insert into messaggi (username,password,user,gender,date_of_birth,country,test_arousal_photo1,test_valence_photo1 ,test_arousal_photo2,test_valence_photo2,test_arousal_photo3,test_valence_photo3,test_arousal_photo4 ,test_valence_photo4,test_arousal_photo5,test_valence_photo5,test_arousal_photo6,test_valence_photo6 ,test_arousal_photo7,test_valence_photo7,test_arousal_photo8,test_valence_photo8,test_arousal_photo9 ,test_valence_photo9,test_arousal_photo10,test_valence_photo10,date)
values (' $username ',' $psw ',
'" . $_SESSION['user']. "','" . $_SESSION['gender'] . "','" . $_SESSION['year'] . "-" . $_SESSION['month'] . "-" . $_SESSION['day'] . "','" . $_SESSION['country'] . "','" . $_SESSION['test_arousal_photo1'] . "','" . $_SESSION['test_valence_photo1'] . "','" . $_SESSION['test_arousal_photo2'] . "','" . $_SESSION['test_valence_photo2'] . "','" . $_SESSION['test_arousal_photo3'] . "','" . $_SESSION['test_valence_photo3'] . "','" . $_SESSION['test_arousal_photo4'] . "','" . $_SESSION['test_valence_photo4'] . "','" . $_SESSION['test_arousal_photo5'] . "','" . $_SESSION['test_valence_photo5'] . "','" . $_SESSION['test_arousal_photo6'] . "','" . $_SESSION['test_valence_photo6'] . "','" . $_SESSION['test_arousal_photo7'] . "','" . $_SESSION['test_valence_photo7'] . "','" . $_SESSION['test_arousal_photo8'] . "','" . $_SESSION['test_valence_photo8'] . "','" . $_SESSION['test_arousal_photo9'] . "','" . $_SESSION['test_valence_photo9'] . "','" . $_SESSION['test_arousal_photo10'] . "','" . $_SESSION['test_valence_photo10'] . "', now())" ) or die (mysql_error());echo " hai effettuato la registrazione con successo<br>can see the final statistics <a href="finalstat.php">stat</a>.";
}
@mysql_close($connection);?>
</body>
</html>
-
fai una query prima e se restituisce 1 o + risultati...non fai la 2° e stampi un errore!
-
che query faccio prima?
-
perchè anche nel database mi scrive 2 o piu' volte lo stesso utente e la stessa password.
qualche controllo che nn va...eppure mi sembrano giusti
-
ma 2 o + volte a stessa esecuzione di query?????
-
basta che digito n volte lo stesso username e password e me lo riscrive n volte nel database