Ciao ragazzi, intanto salve a tutti.

Avrei un problema... Ho uno script in php che mi dovrebbe consentire sia di creare un nuovo utente sia di modificarne uno già esistente...
Il problema è che quando ne creo uno nuovo non mi scrive la password sul database e quando ne modifico uno non mi crea gli aggiornamenti..

Gli errori sono senz'altro sulle query: insert into... e update... ma non riesco a trovarli... Posto il codice.

Grazie in anticipo


<?php defined( '_INIT' ) or die(); ?>

<h1>Modifica Informazioni Amministratore</h1>

<?php


if (isset($_POST[send_form]) AND $_POST[send_form] == 1)
{

$nome = $_POST[nome];
$username = $_POST[username];
$email = $_POST[email];
$password = $_POST[password];


// per prevenire la creazione di account duplicati, ci basiamo sulla username che deve essere UNICA
$sql = "SELECT username FROM ". PREFIX . 'Accounts' ." WHERE username = '$username' AND cID != '$_GET[cID]'";
$do_sql = mysql_query($sql);
$num = mysql_numrows($do_sql);
if ($num > 0)
{
echo '<p class="errore">Esiste già un amministratore con questa username.</p>';
$_ERROR = 1;
}


// verifica della username...
if ($nome == '')
{
echo '<p class="errore">Specifica il Nome</p>';
$_ERROR = 1;
}


// controllo sulla password
if (isset($_GET[cID]))
{
if ($password == '')
{
$password_check1 = '';
} else {
$password_check1 = "password = '". md5($password) ."', ";
$password_check2 = 'password, ';
$password_check3 = "'". md5($password) ."', ";
}
} else {
// stiamo creando un nuovo utente...
// la password è obbligatoria!
if ($password == '' OR strlen($password) < 6 OR strlen($password) > 25)
{
// se non è specificata fermiamo la query...
echo '<p class="errore">Specifica Password</p>';
$_ERROR = 1;
}
}


// verifica della username...
if ($username == '' OR strlen($username) < 6 OR strlen($username) > 25)
{
echo '<p class="errore">Specifica Username: la username deve essere di almeno 6 caratteri e al massimo 25, attualmente hai specificato '. htmlentities($username) .' che è lunga '. strlen($username) .' caratteri...</p>';
$_ERROR = 1;
}


if (!email_check($email))
{
echo '<p class="errore">Verifica indirizzo email...</p>';
$_ERROR = 1;
}



[B]// Modifica dei dati

if ($_ERROR != 1)
{

if (isset($_GET[cID]) AND $_GET[cID] != '')
{
$sql = "UPDATE ". PREFIX . 'Accounts' ." SET username = '$username', nome = '$nome', ". $password_check1 ." email = '$email' WHERE cID = '". $_GET[cID] ."'";
} else {
$sql = "INSERT INTO ". PREFIX . 'Accounts' ." (username, ". $password_check2 ." email, nome) VALUES ('$username', ". $password_check3 ." '$email','$nome')";
}


$do_sql = @mysql_query($sql) or stampa_errore('Errore con la query: '. $sql);

if (isset($_GET[cID]) AND $_GET[cID] != '')
{
echo 'Dati modificati con successo!';
echo '
';
} else {
echo 'Dati creati con successo! Modifica le informazioni.';
echo '
';
}
}

}[B/]

// verifichiamo la varibaile $_GET[CID] per sapere
// se stiamo estrapolando i dati dal database, e in tal caso cID sarà definita e diversa da vuoto....
if ($_GET[cID] != '')
{
// verifichiamo i dati dell'amministratore prendendoli dal database
// e riferendoci a cID...
$sql = "SELECT * FROM ". PREFIX . 'Accounts' ." WHERE cID = '". $_GET[cID] ."'";
$do_sql = @mysql_query($sql) or stampa_errore('Errore con la query: '. $sql);
$info = @mysql_fetch_array($do_sql);

// abbiamo le info dell'utente...
// le abbiamo salvate in una array...
if (!$info)
{
// l'array non funziona, abbiamo sbagliato tutto...
// o forse l'utente con cID = $_GET[cID] non esiste???
echo '<p class="errore">Informazioni Utente non valide</p>';
return;
}

// con la super funzione converto TUTTI gli indici dell'array in un formato
// f_NOMEINDICE per ottenere delle variabili pronte all'uso...
while ( list($key,$val) = each($info) )
{
$f_check = 'f_'. $key;
$$f_check = $info[$key];
}


// questo else, chiude il controllo sulla varaibile cID...
} else {

// essendo la variabile cID non definita, o comunque qvuota...
// vuol dire che stiamo creando un nuovo account, perntanto ripetiamo la super funzione ma
// basiamoci sulle informazioni prese dall'array $_POST...
while ( list($key,$val) = each($_POST) )
{
$f_check = 'f_'. $key;
$$f_check = $_POST[$key];
}
}

// uff!
// piccolo hack per evitare di distruggere la password...

if (isset($_GET[cID]))
{
// stiamo modificando
// nascondiamo la password...
// per la privacy
$f_password = '';
}


?>


<form method="POST" action="">
<input type="hidden" name="send_form" value="1">
<table border="0" cellpadding="2" width="100%">
<tr>
<td width="165" align="right">Nome:</td>
<td><input type="text" name="nome" size="35" value="<?php echo $f_nome ?>"></td>
</tr>
<tr>
<td height="21" width="165" align="right">Username:</td>
<td height="21"><input type="text" name="username" size="25" value="<?php echo $f_username ?>"></td>
</tr>
<tr>
<td height="21" width="165" align="right">Password:</td>
<td height="21"><input type="text" name="password" size="25" value="<?php echo $f_password ?>"></td>
</tr>
<tr>
<td width="165" align="right">Email:</td>
<td><input type="text" name="email" size="50" value="<?php echo $f_email ?>"></td>
</tr>
<tr>
<td width="165" align="right"></td>
<td></td>
</tr>
<tr>
<td width="165" align="right"></td>
<td></td>
</tr>
<tr>
<td width="165"></td>
<td><input type="submit" value="Salva" name="B1"></td>
</tr>
</table>


</p>
</form>





// Modifica dei dati [B]