<?php

     $user = htmlspecialchars($_POST['user']);
     $pass = htmlspecialchars($_POST['pass']);

     $con = mysqli_connect("localhost", "bluemark_OMHwp", "dtZtX8e9Xd1X", "bluemark_OMHwp")or die(json_encode("unconnected"));

     //coverte dados da tabela para utf8 devido aos acentos nos textos da tabela
     if (!mysqli_set_charset($con, "utf8")) 
     {
         json_encode("erro de caracter");
     } 

     $result = mysqli_query($con,"SELECT * FROM LM_MariaHelena_Users WHERE User='".$user."' and Pass='".$pass."'");
     $row = mysqli_fetch_array($result);

     if($row=="")
     {
          echo '<h1>Acesso nao autorizado</h1>';
          echo '<meta http-equiv="refresh" content="2;url=index.php" />';
     }
     else
     {
          session_start();

          session_regenerate_id();
          $_SESSION['password']=$row['UserID'].','.$row['User'].','.$row['Pass'].','.$row['Nivel'];
          $_SESSION['passUser']='ty73bhtgm352edr4';
   
          echo '<meta http-equiv="refresh" content="0;url=index.php" />';
     }
   
     mysqli_close($con);


?>