Jump to content

Recommended Posts

Posted

Boas,

Tenho um login sem Base de dados, ou seja, Basta a pessoa colocar certas credenciais e pode entrar.

Agora gostaria de saber se com este codigo consigo colocar mais utilizadores.

<?php

require("index.html");

$login = $_POST['login'];

$password = $_POST['password'];

if($login !=admin || $password !=admin ){

header("Location:index.html");}

else

{header("Location:Administrador.php");}

?>

Posted (edited)

if($login == 'Portugal' && $password == 'Programar' || $login == 'PAP' && $password == 'Portugal'){
  header('location: administrador.php');
}else{
  header('location: index.html');
}
exit();
Edited by bioshock
Posted

Hmmn, podes fazer um array associativo, e verificar se o id existe quando verificas o input do utilizador. Por exemplo:

<?php
   $users = array("user1" => "pass1", "user2" => "pass2");

   $login = $_POST['login'];
   $password = $_POST['password'];

   if (isset($users[$login]) && $users[$login] == $password){
      echo "Sucesso!";
   }else
      echo "Login falhou";
  • Vote 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.