114 lines
3.4 KiB
PHP
114 lines
3.4 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="pt-br">
|
|
<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">
|
|
<link rel="stylesheet" href="estilo.css">
|
|
<title>Aula 12</title>
|
|
</head>
|
|
<body>
|
|
<header><h1>Aula 12 - Grava texto</h1></header>
|
|
|
|
<nav>
|
|
<button></button>
|
|
</nav>
|
|
<main>
|
|
<table>
|
|
<form action="aula12.php" method="POST">
|
|
<tr><td>CADASTRO<td></td></td></tr>
|
|
<tr><td>Matrícula:</td><td><input type="text" name="mat"></td></tr>
|
|
<tr><td>Nome:</td><td><input type="text" name="nome"></td></tr>
|
|
<tr><td>Nota 1:</td><td><input type="text" name="n1"></td></tr>
|
|
<tr><td>Nota 2</td><td><input type="text" name="n2"></td></tr>
|
|
<tr><td><td></td></td></tr>
|
|
<tr><td>CONSULTA</td><td></td></tr>
|
|
<tr><td>Matrícula</td><td><input type="text" name="matc"></td></tr>
|
|
<tr><td>lista:</td><td><input type="checkbox" name="lista"></td></tr>
|
|
<tr><td><td></td></td></tr>
|
|
<tr><td><input type="reset" value="Apaga"></td><td><input type="submit" value="Envia"></td></tr>
|
|
</form>
|
|
</table>
|
|
|
|
<?php
|
|
if(isset($_POST["mat"])){
|
|
$mat = $_POST["mat"];
|
|
}
|
|
else{
|
|
$mat = null;
|
|
}
|
|
|
|
if(isset($_POST["n1"])){
|
|
$n1 = $_POST["n1"];
|
|
}
|
|
else{
|
|
$n1 = null;
|
|
}
|
|
|
|
if(isset($_POST["n2"])){
|
|
$n2 = $_POST["n2"];
|
|
}
|
|
else{
|
|
$n2 = null;
|
|
}
|
|
|
|
if(isset($_POST["nome"])){
|
|
$nome = $_POST["nome"];
|
|
}
|
|
else{
|
|
$nome = null;
|
|
}
|
|
|
|
if(isset($_POST["matc"])){
|
|
$rec = $_POST["matc"];
|
|
}
|
|
else{
|
|
$matc = null;
|
|
}
|
|
|
|
if(isset($_POST["lista"])){
|
|
$lista = $_POST["lista"];
|
|
}
|
|
else{
|
|
$lista = null;
|
|
}
|
|
|
|
if($mat != null and $nome != null and $n1 != null and $n2 != null){
|
|
$me = ($n1 + $n2) / 2;
|
|
if ($me >=6) {
|
|
echo"<p class='verd'>$nome foi aprovado com a média $me</p>";
|
|
$texto = "<p class='verd'>$nome foi aprovado com a média $me</p>";
|
|
}
|
|
|
|
else{
|
|
echo"<p class='verm'>$nome foi reprovado com a média $me</p>";
|
|
$texto = "<p class='verm'>$nome foi reprovado com a média $me</p>";
|
|
}
|
|
|
|
$arquivo = "lista.txt";
|
|
$fp = fopen($arquivo, "a");
|
|
fwrite($fp, $texto);
|
|
fclose($fp);
|
|
|
|
$arquivo = $mat.".txt";
|
|
$fp = fopen($arquivo, "a");
|
|
fwrite($fp, $texto);
|
|
fclose($fp);
|
|
|
|
}
|
|
if ($matc != null) {
|
|
$arquivo = $matc. "txt";
|
|
$contents = fread($fp, filesize ($arquivo));
|
|
echo"$contents";
|
|
fclose($fp);
|
|
|
|
}
|
|
else {
|
|
echo"<p class='verm'>Arquivo não encontrado!</p>";
|
|
}
|
|
|
|
?>
|
|
</main>
|
|
</body>
|
|
</html>
|