Advertisement
Guest User

Untitled

a guest
Feb 28th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2. //array con usuarios y contraseñas
  3. $usu=array(
  4.     "Austria" => "Austria",
  5.     "Christian" => 123,
  6.     "Poopoo" => 456,);
  7. //recibe los datos del usuario desde el formulario
  8. $User=$_POST['user'];
  9. $Password=$_POST['password'];
  10. //asigna num aleatorio a la variable
  11.    
  12. if ($usu[$User]==$Password && $Password!="") {
  13.     //al comprobar que es correcto, crea cookies y redirige
  14.     if ($User==Austria) {
  15.         $tipus=0; //Admin
  16.         } else if ($User==Christian) {
  17.             $tipus=1; //Jefe
  18.             } else {
  19.                 $tipus=2; //Administrativo
  20.                 }
  21.    
  22.     switch ($tipus]) {
  23.             case 0: header("Location: admin.php");
  24.                     break;
  25.             case 1: header("Location: productes.php");
  26.                     break;
  27.             case 2: header("Location: clients.php");
  28.                     break;
  29.     }
  30.    
  31.     setcookie('dades', $Usu, time()+300);
  32.     header("Location: index2.php");        
  33. }else {
  34.     //no coindice y envia a pagina de error
  35.     setcookie('error', 'error', time()+1);
  36.     header("Location: index.php");
  37.     }      
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement