update nuova password

jimmybuz

Nuovo Utente
22 Apr 2005
1
0
0
ciao ho la necessità di fare un update sulla vecchiapassword con quella nuova.Essendo poco pratico allego tutto il codice fatto fino ad ora per potermi far dire esattamente l'istruzione e sopratutto dove collocarla.....vi prego aiutatemi altrimenti mi licenziano.........ciao

<?php
include_once("Include/Costants.php");
$szConn = getConnection();

if (isset($_REQUEST["cboNome"]))
{
$szNome = $_REQUEST["cboNome"];
}

if (isset($_REQUEST["cboCognome"]))
{
$szCognome = $_REQUEST["cboCognome"];
}

if (isset($_REQUEST["cboUser"]))
{
$szUser = $_REQUEST["cboUser"];
}

if (isset($_REQUEST["txtNascosto"]))
{
$szInserisci = $_REQUEST["txtNascosto"];
}
if (isset($_REQUEST["txtoldpsw"]))
{
$old = $_REQUEST["txtoldpsw"];
}
if (isset($_REQUEST["txtnewpsw"]))
{
$new = $_REQUEST["txtnewpsw"];
}


print "
<html>
<head>
<TITLE> CAMBIO PASSWORD </TITLE>
</head>
<body bgcolor= 'yellow'>
<form name ='frmCambioPsw' method='get'>
<div align='center'><b><h1>Cambio Password </h1></b></div>
<table width= '40%' border='10' align='center'>
<tr>
<td> Nome </td>

<td>";
$SzSql = "SELECT nome FROM accesso ORDER by nome ASC";
$recordset = mysql_query($SzSql, $szConn);

print"
<select name ='cboNome'>
<option></option>";

if (isset($szNome))
{
print "<option SELECTED value='$szNome'>$szNome</option>";
}

while ($Var= mysql_fetch_row ($recordset))
{
print"<option value ='$Var[0]'>$Var[0]</option>";
}
print "
</select>
</td>
</tr>

<tr>
<td> Cognome </td>

<td>";
$SzSql = "SELECT cognome FROM accesso ORDER by cognome ASC";
$recordset =mysql_query($SzSql, $szConn);

print "
<select name='cboCognome'>
<option></option>";

if (isset($szCognome))
{
print "<option SELECTED value='$szCognome'>$szCognome</option>";
}

while ($Var= mysql_fetch_row ($recordset))
{
print"
<option value ='$Var[0]'>$Var[0]</option>";
}
print"
</select>
</td>
</tr>

<tr>
<td> User name </td>

<td>";
$SzSql = "SELECT user_name FROM accesso ORDER by user_name ASC";
$recordset =mysql_query($SzSql, $szConn);

print"
<select name='cboUser'>
<option></option>";

if (isset($szUser))
{
print "<option SELECTED value='$szUser'>$szUser</option>";
}

while ($Var= mysql_fetch_row ($recordset))
{
print"
<option value ='$Var[0]'>$Var[0]</option>";
}
print"
</select>
</td>
</TR>

<tr>
<td>Vecchia password </td>
<td><input type='password' name= 'txtoldpsw' value='$old' size= '8'></td>
</TR>

<tr>
<td>Nuova password </td>
<td><input type='text' name= 'txtnewpsw' value='$new' size= '8'></td>
</TR>

<tr>
<td>Riconferma password </td>
<td><input type='text' name= 'txtnewpsw2' value='$new2' size='8'></td>
</tr>

<tr>
<td><input type='button' value='Inserisci' onclick='javascript: Salva()'></td>
</tr>
</table>

<input type='' name='txtNascosto' size ='1' value='$szInserisci'>
</form>
</body>

<script language= 'javascript'>
function Salva()
{
if (document.all.item('cboNome').value == '')
{
alert('Inserire un valore per i campo Nome');
}
else
{
if (document.all.item('cboCognome').value == '')
{
alert('Inserire un valore per i campo Cognome');
}
else
{
if (document.all.item('cboUser').value == '')
{
alert('Inserire un valore per i campo User');

}
else
{
if (document.all.item('txtoldpsw').value == '')
{
alert('Inserire un valore per i campo oldpass');
}
else
{
document.all.item('txtNascosto').value = 'Ok';
document.forms['frmCambioPsw'].submit();
}
}
}
}
}




</script>
</html>
";
if($szInserisci == "Ok")
{
$Sql = "SELECT * FROM accesso WHERE nome = '$szNome' AND cognome='$szCognome' AND user_name='$szUser' AND Password = '$old'";
$recordset = mysql_query($Sql, $szConn);
$szRows = mysql_fetch_row($recordset);

if (isset($szRows[0]))
{
UPDATE accesso SET Password = '$new' WHERE nome = '$szNome' cognome='$szCognome' user_name='$szUser' ;
}
else
{
print "
<SCRIPT language='JavaScript'>
alert('Utente inesistente.')

document.all.item('txtoldpsw').value = '';
</SCRIPT>";

}

}
 

Discussioni simili