I have a question regarding login for several people. I have this code:
<?php
include("conectar.php");
$usuario = $_POST['usuario'];
$senha = $_POST['senha'];
$query = "
SELECT count(*)
FROM usuarios
WHERE usuario = '" . $usuario . "' AND senha = '" . $senha . "'";
$consulta = mysql_query($query);
$resultado = mysql_fetch_array($consulta);
if ($resultado[0]) {
echo "Login realizado com sucesso!";
}
else {
echo "Dados incorretos.";
}
?>
Each Login will have a specific data to display from a tb_company table. When I log in, I need to show this worker's data. I know it's necessary to do a query for each user. If the login is done by Y it does the query Y and it shows the data Y. If the login is made by Z it does the query Z and it shows the data Z. But I do not know how to do that.
The same data can be found in a MySQL database. The only data that can be related is ID_empresa
and ID_usuario
.