Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alterações atividades #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions exemplo_alunos/code/db/banco.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ INSERT INTO `tb_turma` (`id`, `nome`, `id_curso`) VALUES
(1, 'Turma 2009', 1),
(2, 'Turma de 2010', 2),
(3, '2a', 2);

INSERT INTO `usuarios` (`id`, `login`, `senha`) VALUES
(1, 'layza', '123');
3 changes: 2 additions & 1 deletion exemplo_alunos/code/model/aluno_dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ class AlunoDao
{
private $conexao;

public function __construct(Conexao $conexao)
public function __construct()
{
$conexao = new Conexao();
$this->conexao = $conexao->conectar();
}

Expand Down
3 changes: 2 additions & 1 deletion exemplo_alunos/code/model/curso_dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ class CursoDao
{
private $conexao;

public function __construct(Conexao $conexao)
public function __construct()
{
$conexao = new Conexao();
$this->conexao = $conexao->conectar();
}

Expand Down
8 changes: 5 additions & 3 deletions exemplo_alunos/code/model/matricula_dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ class MatriculaDao
{
private $conexao;

public function __construct(Conexao $conexao)
public function __construct()
{
$conexao = new Conexao();
$this->conexao = $conexao->conectar();

}

public function inserir(Matricula $matricula)
Expand All @@ -36,10 +38,10 @@ public function listar_tudo()
$matriculas = array();

foreach ($resultados as $matricula) {
$alunoDao = new AlunoDao(new Conexao());
$alunoDao = new AlunoDao();
$aluno = $alunoDao->buscar_id($matricula->id_aluno);

$turmaDao = new TurmaDao(new Conexao());
$turmaDao = new TurmaDao();
$turma = $turmaDao->buscar_id($matricula->id_turma);

$nova_matricula = new Matricula($matricula->id, $aluno, $turma, $matricula->data_matricula);
Expand Down
7 changes: 4 additions & 3 deletions exemplo_alunos/code/model/turma_dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class TurmaDao
{
private $conexao;

public function __construct(Conexao $conexao)
public function __construct()
{
$conexao = new Conexao();
$this->conexao = $conexao->conectar();
}

Expand All @@ -34,7 +35,7 @@ public function listar_tudo()
$turmas = array();

foreach ($resultados as $turma) {
$cursoDao = new CursoDao(new Conexao());
$cursoDao = new CursoDao();
$curso = $cursoDao->buscar_id($turma->id_curso);

// $novo_curso = new Curso($turma->id_curso, $turma->nome_curso);
Expand All @@ -54,7 +55,7 @@ public function buscar_id($id)

$resultado = $stmt->fetch(PDO::FETCH_OBJ);

$cursoDao = new CursoDao(new Conexao());
$cursoDao = new CursoDao();
$curso = $cursoDao->buscar_id($resultado->id_curso);

$nova_turma = new Turma($resultado->id, $resultado->nome, $curso);
Expand Down
27 changes: 27 additions & 0 deletions exemplo_alunos/code/model/usuario.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

class Usuario
{
private $id;
private $login;
private $senha;


public function __construct($id, $login, $senha)
{
$this->id = $id;
$this->login = $login;
$this->senha = $senha;

}

public function __get($atributo)
{
return $this->$atributo;
}

public function __set($atributo, $valor)
{
$this->$atributo = $valor;
}
}
30 changes: 30 additions & 0 deletions exemplo_alunos/code/model/usuario_dao.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

require_once '../db/conexao.php';
require_once 'usuario.php';

class UsuarioDao

{
private $conexao;

public function __construct()
{
$conexao = new Conexao();
$this->conexao = $conexao->conectar();
}














}
18 changes: 18 additions & 0 deletions exemplo_alunos/code/public/autenticao.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
$nome = $_POST["login"];
$senha = $_POST["senha"];


if ($nome == "layza" && $senha = "123") {
session_start();
$_SESSION["logado"] = true;
$_SESSION["login"] = "layza";
$_SESSION["senha"] = "123";


header("Location: logado.html");

}
else
header ("Location: erro.php");
?>
1 change: 1 addition & 0 deletions exemplo_alunos/code/public/erro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Erro!<h1>
32 changes: 18 additions & 14 deletions exemplo_alunos/code/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,30 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>

</head>

<body>
<h1>Bem vindo</h1>

<h3>Controle de Alunos</h3>
<a href="cadastrar_aluno.html">Cadastro de aluno</a> <br>
<a href="listar_alunos.php">Listar alunos</a> <br><br>
<h2>Autenticação de Usuário</h2>

<form method="POST" action="autenticao.php">
<label>Login:</label><input type="text" name="login" id="login"><br>
<br>
<label>Senha:</label><input type="password" name="senha" id="senha"><br>

<h3>Controle de Curso</h3>
<a href="cadastrar_curso.html">Cadastro de curso</a> <br>
<a href="listar_cursos.php">Listar cursos</a> <br><br>
<br>
<input type="submit" value="entrar" id="entrar" name="entrar"><br>

<h3>Controle de Turma</h3>
<a href="cadastrar_turma.php">Cadastro de turma</a> <br>
<a href="listar_turmas.php">Listar turmas</a> <br><br>

<h3>Controle de Matrícula</h3>
<a href="cadastrar_matricula.php">Realizar matrícula</a> <br>
<a href="listar_matriculas.php">Listar matrículas</a> <br><br>
</body>
<br>
<form action="user_desconhecido.php" methot="get"></form>
<a href="user_desconhecido.php">Continuar sem logar</a>

</html>




6 changes: 3 additions & 3 deletions exemplo_alunos/code/public/listar_alunos.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<th>endereco</th>
<th>telefone</th>
<th>data nascimento</th>

<?php
require_once '../model/aluno_dao.php';
$conexao = new Conexao();
$alunoDao = new AlunoDao($conexao);

$alunoDao = new AlunoDao();

$alunos = $alunoDao->listar_tudo();

Expand Down
4 changes: 2 additions & 2 deletions exemplo_alunos/code/public/listar_cursos.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

<?php
require_once '../model/curso_dao.php';
$conexao = new Conexao();
$cursoDao = new CursoDao($conexao);

$cursoDao = new CursoDao();

$cursos = $cursoDao->listar_tudo();

Expand Down
3 changes: 1 addition & 2 deletions exemplo_alunos/code/public/listar_matriculas.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

require_once '../model/matricula_dao.php';

$conexao = new Conexao();
$matriculaDao = new MatriculaDao($conexao);
$matriculaDao = new MatriculaDao();

$matriculas = $matriculaDao->listar_tudo();

Expand Down
1 change: 0 additions & 1 deletion exemplo_alunos/code/public/listar_turmas.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

require_once '../model/turma_dao.php';

$conexao = new Conexao();
$turmaDao = new TurmaDao($conexao);

$turmas = $turmaDao->listar_tudo();
Expand Down
27 changes: 27 additions & 0 deletions exemplo_alunos/code/public/logado.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login realizado com sucesso!</title>

<h3>Controle de Alunos</h3>
<a href="cadastrar_aluno.html">Cadastro de aluno</a> <br>
<a href="listar_alunos.php">Listar alunos</a> <br><br>

<h3>Controle de Curso</h3>
<a href="cadastrar_curso.html">Cadastro de curso</a> <br>
<a href="listar_cursos.php">Listar cursos</a> <br><br>

<h3>Controle de Turma</h3>
<a href="cadastrar_turma.php">Cadastro de turma</a> <br>
<a href="listar_turmas.php">Listar turmas</a> <br><br>

<h3>Controle de Matrícula</h3>
<a href="cadastrar_matricula.php">Realizar matrícula</a> <br>
<a href="listar_matriculas.php">Listar matrículas</a> <br><br>
</body>

</html>
23 changes: 23 additions & 0 deletions exemplo_alunos/code/public/user_desconhecido.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Usuário não autenticado</title>

<h3>Alunos</h3>
<a href="listar_alunos.php">Listar alunos</a> <br><br>

<h3>Cursos</h3>
<a href="listar_cursos.php">Listar cursos</a> <br><br>

<h3>Turmas</h3>
<a href="listar_turmas.php">Listar turmas</a> <br><br>

<h3>Matrículas</h3>
<a href="listar_matriculas.php">Listar matrículas</a> <br><br>
</body>

</html>
5 changes: 5 additions & 0 deletions exemplo_alunos/code/test/teste_senha.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
echo md5("senha123");
echo "<br>";
echo md5("teste");
?>