<?php
$r = "";
require_once($r."inc/funciones.php");
validNotSession($r);
$mysqli = connectDB($r);
if(isset($_POST["change"])) {
	$password1 = $_POST["password1"];
	$password2 = $_POST["password2"];
	if($password1 == $password2) {
		$upd1 = $mysqli->query("UPDATE z_usuarios SET contraseña = sha1('".$_POST["password2"]."'), cpass = '' WHERE id = '".$_SESSION["userid"]."'");
		exit(header("Location:".$r."dashboard.php"));
	} else $error = "Password no coinciden, intentelo nuevamente";
}
?>
<!DOCTYPE html>
<html lang="en">

<head><meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>SB Admin - Start Bootstrap Template</title>
  <!-- Bootstrap core CSS-->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom fonts for this template-->
  <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <!-- Custom styles for this template-->
  <link href="css/sb-admin.css" rel="stylesheet">
</head>

<body class="bg-dark">
  <div class="container">
    <div class="card card-login mx-auto mt-5">
      <div class="card-header">Iniciar Session</div>
      <div class="card-body">
              <form role="form" class="parsley-form" data-parsley-validate action="cpass.php" method="post" >
                <div class="form-group">
                <label for="correo">Nueva Constraseña</label>
                <input type="password" class="form-control input-lg mt15" name="password1" required placeholder="password nuevo" />
          </div>
          <div class="form-group">
            <label for="contrasena">Confirmar Constraseña</label>
                <input type="password" class="form-control input-lg mt15" name="password2" required placeholder="confirmar password" />
                <button type="submit" class="btn btn-primary btn-lg btn-block mt15" name="change" value="change">cambiar</button>
              </form>
        <? if($error!=''){ echo '<hr/><div class="alert alert-danger alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.$error.'</div>';} ?>
        <hr/>
      </div>
    </div>
  </div>
  <!-- Bootstrap core JavaScript-->
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="js/form.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <!-- Core plugin JavaScript-->
  <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
</body>

</html>
