PHP FUNCTIONS
<?
if($_REQUEST['salva_ed']){
$sqlu="update registration set username='$username', firstname='$fname', lastname='$lname', sex='$gender',
birth_date='$bdate', addressline1='$address1',addressline2='$address2', complemento='$address3', numero='$address4', city='$city', state='$state',
country='$country', postcode='$zipcode', phone='$phone', mobile_no='$mobileno', full_mobileno='$fullmobile',
email='$email', password=MD5('$pass'), cpf='$cpf',rg='$rg' where id='$id'";
$resultu=mysql_query($sqlu);
header("location:message.php?msg=3"); exit;
}
if($_REQUEST['salva_nv']){
$verifcode = md5($username);
$agora=Date("Y-m-d H:i:s");
$sqlu="insert into registration (username,firstname,lastname,sex,birth_date,addressline1,addressline2,city,state,
country,postcode,phone,mobile_no,full_mobileno,email,password,cpf,rg,register_date,verify_code,
final_bids,account_status,member_status,user_delete_flag,sponser,sms_flag,admin_user_flag) values
('$username','$fname','$lname','$gender','$bdate','$address1','$address2','$address3','$address4','$city','$state',
'$country','$zipcode','$phone','$mobileno','$fullmobile','$email',MD5('$pass'),'$cpf','$rg','$agora','$verifcode',
0,0,'0','',0,'0','0')";
//echo $sqlu; exit;
$resultu=mysql_query($sqlu);
header("location:message.php?msg=2"); exit;
}
?>
HTML
<tr>
<td class="normal" align="right"><font class="a">*</font> Senha de acesso: </td>
<td><input style="width:60%" type="password" name="pass_word" value="<?=$pass?>"/></td>
</tr>
<tr>
<td class="normal" align="right"><font class="a">*</font> Confirmação de senha: </td>
<td><input style="width:60%" type="password" name="cpassword" value="<?=$pass?>"/></td>
</tr>
<input type="submit" value="Atualizar cadastro" name="Editar" class="bttn" /></td>
Personally, I have a problem here and I could not find a solution.
This is an admin panel, I implemented it to save MD5 passwords in DB.
There are two functions, one to execute when you are editing a current client and another to create a new client (salva_nv) ...
The problem is in the function of editing the client (salva_ed), in the password fields.
When I edit it it again changes the client password generating another MD5.
How do I check if the registry is the same in the column, and not replace the current password?
When loading the page it automatically fills in the fields with the current password, however it shows in MD5, so if I save it it will change in the DB generating a new MD5 key.
I saw on the internet that it is possible to use "constraint" to accomplish this task, but I could not implement it.
Does anyone have any tips?