Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once 'config.php';
- global $pdo;
- //Here you can see the fields in the student table: nome, fone and email.
- And only one field in the pay table that is: situacao_aluno
- $sql = "select * from alunos left join pagamentos on id_alunos =
- pagamentos.alunos_id order by nome";
- $sql = $pdo->query($sql);
- if ($sql->rowCount() > 0) {
- foreach ($sql->fetchAll() as $aluno):
- ?>
- <tr>
- <td> <?php echo $aluno['nome']; ?> </td>
- <td> <?php echo $aluno['fone']; ?> </td>
- <td> <?php echo $aluno['email']; ?> </td>
- <td> <?php echo $aluno['situacao_aluno']; ?> </td>
- <?php
- echo "<td><a href='editar.php?id_alunos=" . $aluno['id_alunos'] . "'
- class='btn btn-dark' role='button'>Update</a></td>";
- echo "<td><a href='delete_submit.php?id_alunos=" . $aluno['id_alunos'] .
- "' class='btn btn-danger'>Delete</a></td>";
- echo "</tr>";
- ?>
- <?php
- include_once 'includes/header.inc.php';
- include_once 'includes/menu.inc.php';
- include_once 'config.php';
- ?>
- <?php
- $id_alunos = (isset($_GET['id_alunos'])) ? $_GET['id_alunos'] : '';
- if (!empty($id_alunos) && filter_var($id_alunos, FILTER_VALIDATE_INT)):
- $ret = array();
- global $pdo;
- $sql = "select * from alunos left join pagamentos on alunos.id_alunos =
- pagamentos.alunos_id where alunos.id_alunos = $id_alunos";
- $sql = $pdo->query($sql);
- if ($sql->rowCount() > 0):
- $ret = $sql->fetchAll()[0];
- endif;
- if(empty($ret)) {
- header('Location: home.php');
- exit(0);
- }
- endif;
- ?>
- <?php
- require 'config.php';
- require 'class/crud.php';
- $id_alunos = (isset($_POST['id_alunos'])) ? $_POST['id_alunos'] : 0;
- if(empty($id_alunos)){
- header('Location: home.php');
- exit(0);
- }
- $altera = new Alunos();
- $nome = addslashes($_POST['nome']);
- $rg = addslashes($_POST['rg']);
- $cpf = addslashes($_POST['cpf']);
- $nascimento = addslashes($_POST['nascimento']);
- $sexo = addslashes($_POST['sexo']);
- $fone = addslashes($_POST['fone']);
- $email = addslashes($_POST['email']);
- $endereco = addslashes($_POST['endereco']);
- $bairro = addslashes($_POST['bairro']);
- $cidade = addslashes($_POST['cidade']);
- $estado = addslashes($_POST['estado']);
- $cep = addslashes($_POST['cep']);
- $situacao_aluno = addslashes($_POST['situacao_aluno']);
- $vencimento_plano = addslashes($_POST['vencimento_plano']);
- $planos = addslashes($_POST['planos']);
- $vencimento = addslashes($_POST['vencimento']);
- $cpf_amigo = addslashes($_POST['cpf_amigo']);
- $forma_pagamento = addslashes($_POST['forma_pagamento']);
- $data_matricula = addslashes($_POST['data_matricula']);
- $numero_documento = addslashes($_POST['numero_documento']);
- $data_documento = addslashes($_POST['data_documento']);
- $valor = addslashes($_POST['valor']);
- $altera->UpdateAlunos($id_alunos, $nome, $rg ,$cpf, $nascimento, $sexo,
- $fone, $email, $endereco, $bairro, $cidade, $estado, $cep);
- $altera->UpdatePagamentos($id_alunos, $email, $situacao_aluno,
- $vencimento_plano, $planos,$vencimento, $cpf_amigo, $forma_pagamento,
- $data_matricula, $numero_documento, $data_documento, $valor);
- header('Location: editar.php?id_alunos='.$id_alunos);
- ?>
- //Here in the case I will only show the UPDATE,
- /*
- * class UpdateAlunos()
- * edit the table students
- */
- public function UpdateAlunos($id_alunos, $nome, $rg, $cpf, $nascimento,
- $sexo, $fone, $email, $endereco, $bairro, $cidade, $estado, $cep)
- {
- global $pdo;
- $sql = $pdo->prepare("update alunos set nome=:nome, rg=:rg, cpf=:cpf,
- nascimento=:nascimento, sexo=:sexo, fone=:fone, email=:email,
- endereco=:endereco, bairro=:bairro, cidade=:cidade, estado=:estado, cep=:cep
- where id_alunos = '$id_alunos'");
- $sql->bindValue(":nome", $nome);
- $sql->bindValue(":rg", $rg);
- $sql->bindValue(":cpf", $cpf);
- $sql->bindValue(":nascimento", $nascimento);
- $sql->bindValue(":sexo", $sexo);
- $sql->bindValue(":fone", $fone);
- $sql->bindValue(":email", $email);
- $sql->bindValue(":endereco", $endereco);
- $sql->bindValue(":bairro", $bairro);
- $sql->bindValue(":cidade", $cidade);
- $sql->bindValue(":estado", $estado);
- $sql->bindValue(":cep", $cep);
- $sql->execute();
- }
- /*
- * class UpdatePagamentos()
- * edit the payments table
- */
- public function UpdatePagamentos($situacao_aluno, $vencimento_plano,
- $planos, $vencimento, $cpf_amigo, $forma_pagamento, $data_matricula,
- $numero_documento, $data_documento, $valor)
- {
- global $pdo;
- $sql = $pdo->prepare("update pagamentos set situacao_aluno=:situacao_aluno,
- vencimento_plano=:vencimento_plano, planos=:planos, vencimento=:vencimento,
- cpf_amigo=:cpf_amigo, forma_pagamento=:forma_pagamento,
- data_matricula=:data_matricula, numero_documento=:numero_documento,
- data_documento=:data_documento, valor=:valor where alunos_id =
- '$id_alunos'");
- $sql->bindValue(":situacao_aluno", $situacao_aluno);
- $sql->bindValue(":vencimento_plano", $vencimento_plano);
- $sql->bindValue(":planos", $planos);
- $sql->bindValue(":vencimento", $vencimento);
- $sql->bindValue(":cpf_amigo", $cpf_amigo);
- $sql->bindValue(":forma_pagamento", $forma_pagamento);
- $sql->bindValue(":data_matricula", $data_matricula);
- $sql->bindValue(":numero_documento", $numero_documento);
- $sql->bindValue(":data_documento", $data_documento);
- $sql->bindValue(":valor", $valor);
- $sql->execute();
- }
Add Comment
Please, Sign In to add comment