Salve a tutti.
Sto cercando di passare la variabile $mypass ad un db mysql perchè l'intento finale è quello di aggiornare il database con una password nuova creata da uno script apposito.
Questo il form iniziale:
codice:
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td>Inserimento dati </td>
</tr>
</table>
<table width="400" border="0" align="left" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="insert.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="16%">Cognome</td>
<td width="2%">:</td>
<td width="82%"><input name="cognome" type="text" id="cognome" size="50"></td>
</tr>
<tr>
<td>Nome</td>
<td>:</td>
<td><input name="nome" type="text" id="nome" size="50"></td>
</tr>
<tr>
<td>Cellulare</td>
<td>:</td>
<td><input name="cellulare" type="text" id="cellulare" size="50"></td>
</tr>
<tr>
<td><input type="hidden" value="<? echo $password; ?>" name="password" id="password" size="50"></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" name="Invia" value="Invia"> <input type="reset" name="Cancella" value="Cancella"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
Mentre questo è lo script per la creazione della password:
codice:
<?php
// Imposto la lunghezza della password a 10 caratteri
$lung_pass = 10;
// Creo un ciclo for che si ripete per il valore di $lung_pass
for ($x=1; $x<=$lung_pass; $x++)
{
// Se $x è multiplo di 2...
if ($x % 2){
$mypass = $mypass . chr(rand(97,122));
// Se $x non è multiplo di 2...
}else{
// Aggiungo alla password un numero compreso tra 0 e 9
$mypass = $mypass . rand(0,9);
}
}
// echo $mypass
?>
Qualcuno sa indicarmi la retta via?
Grazie!