Notice: Undefined index: user in C:\xampp\htdocs\DSagredo\inc\functions.php on line 18
Notice: Undefined index: password in C:\xampp\htdocs\DSagredo\inc\functions.php on line 19
INDEX.PHP
$obj->getLogueo();
if (isset($_GET["m"]) && !empty($_GET["m"]))
{
$error_msg = "<div class='error'>Usuario o contraseña incorrectos</div>";
}
include 'inc/header.php';
?>
<div class="caja">
<div class="foro">
<form method="post" action="#">
<?php echo $error_msg; ?>
<h2>Iniciar sesión</h2>
<input type="text" name="user" id="user" placeholder="Usuario" required autofocus>
<input type="password" name="password" placeholder="Contraseña" required>
<br>
<button class="btn" type="submit">Entrar</button>
</form>
</div>
</div>
FUNCTION.PHP
public function getLogueo()
{
$user = $_POST["user"];
$pass = md5($_POST["password"]);
$res = $this->mysqli->query("SELECT id, name, kind from user where user = '$user' and password = '$pass'");
while ($row = $res->fetch_assoc())
{
$this->login[] = $row;
}
if (sizeof($this->login) > 0)
{
foreach ($this->login as $key)
{
$_SESSION["id"] = $key["id"];
$_SESSION["name"] = $key["name"];
$_SESSION["kind"] = $key["kind"];
switch ($_SESSION["kind"])
{
case 1: header("Location: panel.php");
break;
case 2: header("Location: index2.php");
break;
}
}
} else {
header("Location: index.php?m=1");
}
}