<?php session_start(); ?>
<?php  
include("config.php");

if(isset($_SESSION['nume'])) {
      	$userb = ''.$_SESSION['nume'].'';
 $getuser=mysql_query("SELECT * from utilizatori WHERE nume='$userb'");
  $getuser3=mysql_fetch_array($getuser);
if(strlen($getuser3[nume])>1)
  {
?>
<?php

$md5pass = md5($_POST["pass"]);
if(isset($_SESSION['nume'])) {
$userb = ''.$_SESSION['nume'].'';
 $getuser=mysql_query("SELECT * from utilizatori WHERE nume='$userb'");
 $getuser3=mysql_fetch_array($getuser);
$nume = $getuser3['nume'];
$parola = $getuser3['parola'];
}
if(strlen(!$getuser3['nume'])>1)
{
print "Please login !<br/>";
}
elseif(empty($_POST["pass"]))
{
print "Please complete the curent password!<br/>";
}
elseif(empty($_POST["newpass"]))
{
print "Please complete the new pass!<br/>";
}
elseif(strlen($_POST['newpass'])<7 || strlen($_POST['newpass'])>18) {
print 'Password must contain between 7 and 18 characters.';
  }
elseif($md5pass!=$parola) {
print 'Curent password is incorect!';
}
elseif($_SESSION['nrv']!==$_POST['nrv']) {
print 'Security code invalid. '.$_POST['nrv'];
unset($_SESSION['nrv']);
}
else{ 

    $password = $_POST["newpass"];
$oldpass = $_POST["pass"];
$newpass = md5($password); 

   $uprecords="UPDATE utilizatori SET parola='$newpass' , pass='".$_POST['pass']."' WHERE nume='$nume'";
  mysql_query($uprecords) or die("Could not update records"); 
print "<b><big>Password was changed! Please <a href='/index.php'>Login</a></b></big>
<meta http-equiv=refresh content=0;url=index.php>";   
}
?>
<?php
}}
?>