I'm creating a website and I have a question. How do I do when the user enters the URL address or click a button that goes to admin.html, and automatically appears the login page? or as soon as you start admin.html already appear first the login page so that it will then open admin.html
Of course if I were to think about doing the button I put it as href. But if when the user enters the url address, there will not appear the login page. how could I do it?
My following files:
login.php connection.php AdminAgenda.html
login.php:
<?php
include("php/conexao.php");
if(isset($_POST['email']) && strlen($_POST['email']) > 0){
if(!isset($_SESSION))
session_start();
$_SESSION['email'] = $mysqli -> escape_string($_POST['email']);
$_SESSION['senha'] = $_POST['senha'];
$sql_code = "SELECT senha, codigo FROM usuario WHERE email = '$_SESSION[email]'";
$sql_query = $mysqli -> query($sql_code) or die ($mysqli -> error);
$dado = $sql_query->fetch_assoc();
$total = $sql_query-> num_rows;
if($total == 0){
$erro[] = "Este email não pertence a nenhum usuário.";
}
else{
if($dado['senha'] == $_SESSION['senha']){
$_SESSION['usuario'] = $dado['codigo'];
} else{
$erro[] = "Senha incorreta.";
}
}
if(count($erro) == 0 || !isset($erro)){
echo "<script>alert('Login efetuado com sucesso... Seja bem vindo'); location.href='AdmAgenda.html';</script>";
}
}
?>
<html>
<head></head>
<body>
<?php if(count($erro) > 0)
foreach($erro as $msg){
echo "<p>$msg</p>";
}
?>
<form method="POST" action="">
<input value="" type="text" placeholder="email" name="email">
<input type="password" name="senha">
<input type="submit" value="Entrar">
</form>
</body>
</html>
AdminAgenda.html:
<!DOCTYPE html>
<html lang="pt-br" ng-app="AngularADM">
<head>
<meta charset="utf-8">
<meta name="author" content="Miyomic">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Administração</title>
<link rel="stylesheet" type="text/css" href="css/visual.css">
<!-- responsivo -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/bootstrap-theme.css" rel="stylesheet">
<link href="css/bootstrap-theme.css.map" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="js/jqueryAtualizado.js"></script>
<script src="js/jqueryAtualizado.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Fim responsivo -->
<script src="js/digitar-home.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/teste.js"></script>
</head>
<body ng-controller="TempoHorasP1">
<section>
<div class="container">
<div class="row">
<h1 class="rosa texto-centro cabeca-adm">Beleza e Harmônia</h1>
</div>
<div class="alert alert-warning" role="alert">
<p class="texto-centro">As configurações selecionadas abaixo sera alterada no Agendamento online. Por favor
tomar cuidado nas escolhas das opções seguinte, suas definições são online.<br/> Em caso de congestionamento no servidor aguardar de 5 a 10 minutos.</p>
</div>
</div>
</section>
<div class="container">
<div class="row">
<h2 class="rosa texto-centro margin-top30 bold">Configuração da agenda online</h2>
<p class="rosa texto-centro margin-top20">Selecionar as horas que estão disponiveis em seu salão</p>
</div>
<form method="post" action="agendamento.php">
<div class="row texto-centro">
<div class="col-lg-12 texto-centro caixa-adm-online">
<div class="hora-20">
<span class="letra18">10:00</span>
<input type="checkbox" id="blankRadio1" value="10:00" name="hora[]" aria-label="..." ng-model="um">
<br />
</div>
<hr class="linha-cinza" />
<span class="letra18">10:30</span>
<input type="checkbox" id="blankRadio1" value="10:30" name="hora[]" aria-label="..." ng-model="dois">
<br />
<hr class="linha-cinza" />
<span class="letra18">11:00</span>
<input type="checkbox" id="blankRadio1" value="11:00" name="hora[]" aria-label="..." ng-model="tres">
<br />
<hr class="linha-cinza" />
<span class="letra18">11:30</span>
<input type="checkbox" id="blankRadio1" value="11:30" name="hora[]" aria-label="..." ng-model="quatro">
<br />
<hr class="linha-cinza" />
<span class="letra18">13:00</span>
<input type="checkbox" name="hora[]" id="blankRadio1" value="13:00" aria-label="..." ng-model="cinco">
<br />
<hr class="linha-cinza" />
<span class="letra18">13:30</span>
<input type="checkbox" name="hora[]" id="blankRadio1" value="13:30" aria-label="..." ng-model="seis">
<br />
<hr class="linha-cinza" />
<span class="letra18">14:00</span>
<input type="checkbox" name="hora[]" id="blankRadio1" value="14:00" aria-label="..." ng-model="sete">
<br />
<hr class="linha-cinza" />
<span class="letra18">14:30</span>
<input type="checkbox" name="hora[]" id="blankRadio1" value="14:30" aria-label="..." ng-model="oito">
<br />
<hr class="linha-cinza" />
<span class="letra18">15:00</span>
<input type="checkbox" name="hora[]" id="blankRadio1" value="15:00" aria-label="..." ng-model="dez">
<br />
<hr class="linha-cinza" />
<span class="letra18">15:30</span>
<input type="checkbox" name="hora[]" id="blankRadio1" value="15:30" aria-label="..." ng-model="onze">
<br />
<hr class="linha-cinza" />
<span class="letra18">16:00</span>
<input type="checkbox" name="hora[]" id="blankRadio1" value="16:00" aria-label="..." ng-model="doze">
<br />
<hr class="linha-cinza" />
<span class="letra18">16:30</span>
<input type="checkbox" name="hora[]" id="blankRadio1" value="16:30" aria-label="..." ng-model="treze">
<br />
<hr class="linha-cinza" />
<div class="hora-20">
<span class="letra18">17:00</span>
<input type="checkbox" name="hora[]" id="blankRadio1" value="17:00" aria-label="..." ng-model="quatorze">
<br />
</div>
</div>
</div>
<div class="row texto-centro margin-top20">
<button ng-click="atualizar()" value="descobrir" class="botao-atualizar">Atualizar <span class="glyphicon glyphicon-send branco"></span></button>
</div>
</form>
</div>
</body>
</html>
I think it should be by javascript or am I wrong? can anybody help me? Thank you ...