<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>combo</title>
</head>
<body>
<form action="login.php" method="post">
<table>
<tr>
<td>Usuario:</td>
<td> <input type="text" name="TXTUSUARIO" placeholder="Nombre de Usuario"> </td>
<td><input type="submit" name="BTNACEPTAR" value="Aceptar"> </td>
</tr>
<tr>
<td>Pasword:</td>
<td> <input type="Password" name="TXTPASSWORD" placeholder="Password"> </td>
</tr>
</table>
<?php
// CONEXION CON LA BASE DE DATOS
$server='localhost';
$user='root';
$psw='';
$db='<TU_BASE_DE_DATOS>';
$conexion=@new mysqli ($server,$user,$psw,$db);
if($conexion-> connect_error){
die('Ups ! Sorry I cant Connect to the Database , Trouble -> ' . $conexion->connect_error);
}
if (isset($_POST['BTNACEPTAR'])) { // CUANDO PULSAS EL BOTON DE ACEPTAR
$usuario=$_POST['TXTUSUARIO']; // CREAS VARIABLES Y SE LES ASIGNA EL VALOR DE LAS CAJAS DE TEXTO
$password=$_POST['TXTPASSWORD'];
$sql="SELECT count(*) AS ACCESO FROM tblconfig where tblcUser='".$usuario."' and tblcPsw ='".$password."' "; // CREAS TU CONSULTA
$result=$conexion->query($sql); //EJECUTAS TU CONSULTA
if($result->num_rows > 0){ // SI LA CONSULTA TE DEVUELVE AL MENOS 1 REGISTROS
while ($row=$result->fetch_array(MYSQLI_ASSOC)) { // HACES UN ARREGLO Y LO RECORRES CON EL WHILE
$acceso=$row['ACCESO']; // EL RESULTADO DEL CAMPO LO ASIGNAS A UNA VARIABLE EN ESTE CASO $acceso
}
if ($acceso==1) { // CUANDO EL WHILE TERMINA Y SE SALE COMPARA EL VALOR DE LA VARIABLE, SI ENCUENTRA UNA COICIDENCIA DA ACCESO
echo" el Usuario es correcto";
//header('location: menu.php'); // SI DESCOMENTA ESTA LINEA Y CAMBIAS EL NOMBRE DE LA PAGINA menu.php TE VA A DIRIGIR A LA PAGINA QUE DESEES
}
else { // SI NO ENCUENTRA COINCIDENCIAS NO DA ACCESO
echo" el Usuario o el Password es incorrecto";
}
}
}
?>