I'm working on php and mysql is a web application and I have a database with a table called users with the fields
- user_id
- name
- user_type
- password
And in the user type there could only be two that are ADMINISTRATOR and USER. What I want to do is that when you enter the system depending on the user, some buttons are enabled for example If the user is an administrator, all the buttons are enabled, but if they are a normal user, all are disabled.
This is the code where I used the user data to be able to access the system
<?php
$usuario = $_POST['u'];
$pass= $_POST['p'];
if(empty($usuario) || empty($pass))
{
header("Location: index.html");
exit();
}
mysql_connect('localhost','root','') or die("Error al conectar".mysql_error());
mysql_select_db('horarioescolar') or die("Serror al seleccionlar la base de datos".mysql_error());
$result = mysql_query("SELECT * FROM usuarios where usuario = '".$usuarios."' and passw = '".$pass."'");
if($row = mysql_fetch_array($result)){
if( $row['passw'] == $pass){
session_start();
$_SESSION['usuarios'] = $usuario;
header("Location:contenido.php");
}else{
header("Location:inde.php");
exit();
}
}else{
header("Location:inde.php");
exit();
}