<?php
	session_start();
	$con = mysqli_connect("localhost","medixcad_finanzas","G4t0_H1l0","medixcad_finanzas");
	$user = $_POST['userName'];
	$psswd = $_POST['password'];
	$usuario = mysqli_query($con, "SELECT * FROM users WHERE Nombre=TRIM('$user')");
	if (mysqli_num_rows($usuario) != 0){
	    $u = mysqli_fetch_assoc($usuario);
		if ($u["Psswd"] == $psswd){
			$_SESSION['user'] = $u["Nombre"];
    		echo '<meta http-equiv="refresh" content="0; url=inicio.php">';
		}
		else{
			echo '
				<script>alert("Contraseña incorrecta")</script>
				<meta http-equiv="refresh" content="0; url=index.html">
			';
		}
	}
	else{
		echo '
			<script>alert("Usuario incorrecta")</script>
			<meta http-equiv="refresh" content="0; url=index.html">
		';
	}
?>

