atualizacao aula
This commit is contained in:
181
aula15v2.php
Normal file
181
aula15v2.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<!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">
|
||||
<title>Aula 11</title><link rel="stylesheet" href="estilo.css"> <style>
|
||||
.f2{
|
||||
position: fixed;
|
||||
top: 20%;
|
||||
left: 50%;
|
||||
}
|
||||
.verd{
|
||||
font-size: 120%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body><header><h1>Atividade texto</h1></header>
|
||||
<nav></nav>
|
||||
<main>
|
||||
<form action="aula15.php" method="POST">
|
||||
<table>
|
||||
<tr><th colspan="2">CADASTRO!</th></tr>
|
||||
<tr><td>Nome:</td><td><input type="text" name="nome" size="23"></td></tr>
|
||||
<tr><td>Documento:</td><td><input type="text" name="doc" size="23"></td></tr>
|
||||
<tr><td>Telefone:</td><td><input type="text" name="tel" size="23"></td></tr>
|
||||
<tr><td>Curso:</td><td><select name="curso">
|
||||
<option value="Escolha">Escolha o Curso</option>
|
||||
<option value="Desenvolvimento_de_Sistemas">Desenvolvimento de Sistemas</option>
|
||||
<option value="Administração">Administração</option>
|
||||
<option value="Mecânica">Mecânica</option>
|
||||
<option value="Enfermagem">Enfermagem</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><td><input type="reset" value="Apagar"></td>
|
||||
<td><input type="submit" value="Cadastrar"></td></tr>
|
||||
</table></form>
|
||||
<br><hr><br>
|
||||
|
||||
<div class="f2">
|
||||
|
||||
|
||||
<form action="aula15.php" method="POST">
|
||||
<table>
|
||||
<tr><th colspan="2">VER NOMES CADASTRADOS </th></tr>
|
||||
<tr><td>Curso:</td><td><select name="cursoc">
|
||||
<option value="Escolha">Escolha o Curso</option>
|
||||
<option value="Desenvolvimento_de_Sistemas">Desenvolvimento de Sistemas</option>
|
||||
<option value="Administração">Administração</option>
|
||||
<option value="Mecânica">Mecânica</option>
|
||||
<option value="Enfermagem">Enfermagem</option>
|
||||
</select></td></tr>
|
||||
<tr><td>Nome:</td><td><input type="text" name="nomec" size="23"></td></tr>
|
||||
<tr><td>Registro:</td><td><input type="text" name="reg" size="23"></td></tr>
|
||||
<tr><td><input type="reset" value="Apagar"></td>
|
||||
<td><input type="submit" value="Consultar"></td></tr>
|
||||
</table></form>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
if(isset($_POST["nome"])){
|
||||
$nome = $_POST["nome"];
|
||||
}
|
||||
else{
|
||||
$nome = null;
|
||||
}
|
||||
|
||||
if(isset($_POST["doc"])){
|
||||
$doc = $_POST["doc"];
|
||||
}
|
||||
else{
|
||||
$doc = null;
|
||||
}
|
||||
|
||||
if(isset($_POST["tel"])){
|
||||
$tel = $_POST["tel"];
|
||||
}
|
||||
else{
|
||||
$tel = null;
|
||||
}
|
||||
|
||||
@$curso = $_POST["curso"];
|
||||
if($curso == "Escolha"){
|
||||
$curso = null;
|
||||
}
|
||||
|
||||
@$cursoc = $_POST["cursoc"];
|
||||
if($cursoc == "Escolha"){
|
||||
$cursoc = null;
|
||||
}
|
||||
|
||||
if(isset($_POST["nomec"])){
|
||||
$nomec = $_POST["nomec"];
|
||||
}
|
||||
else{
|
||||
$nomec = null;
|
||||
}
|
||||
|
||||
if(isset($_POST["reg"])){
|
||||
$reg = $_POST["reg"];
|
||||
}
|
||||
else{
|
||||
$reg = null;
|
||||
}
|
||||
|
||||
if($nome != null and $doc != null and $tel != null and $curso != null){
|
||||
$arquivo = "reg.txt";
|
||||
if(@$fp = fopen($arquivo, "r")){
|
||||
$contents = fread($fp, filesize($arquivo));
|
||||
fclose($fp);
|
||||
}
|
||||
$registro = $contents + 1;
|
||||
|
||||
echo"<p class='verd'>Resgistro: $registro $nome Documento: $doc Telefone: $tel foi cadastrado no curso $curso </p>";
|
||||
$texto = "<p class='verd'>Resgistro: $registro $nome Documento: $doc Telefone: $tel foi cadastrado no curso $curso </p>";
|
||||
|
||||
$arquivo = "reg.txt";
|
||||
$fp = fopen($arquivo, "w");
|
||||
fwrite($fp, $registro);
|
||||
fclose($fp);
|
||||
|
||||
$arquivo = $nome.".txt";
|
||||
$fp = fopen($arquivo, "w");
|
||||
fwrite($fp, $texto);
|
||||
fclose($fp);
|
||||
|
||||
$arquivo = $curso.".txt";
|
||||
$fp = fopen($arquivo, "a");
|
||||
fwrite($fp, $texto);
|
||||
fclose($fp);
|
||||
|
||||
$arquivo = $registro.".txt";
|
||||
$fp = fopen($arquivo, "w");
|
||||
fwrite($fp, $texto);
|
||||
fclose($fp);
|
||||
}else{
|
||||
if($nome != null or $doc != null or $tel != null or $curso != null){
|
||||
echo"<p class='verm'>Preencha todos os campos para cadastrar! </p>";
|
||||
}
|
||||
}
|
||||
|
||||
if($cursoc != null){
|
||||
$arquivo = $cursoc.".txt";
|
||||
if(@$fp = fopen($arquivo, "r")){
|
||||
$contents = fread($fp, filesize($arquivo));
|
||||
fclose($fp);
|
||||
echo"$contents";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($nomec != null){
|
||||
$arquivo = $nomec.".txt";
|
||||
if(@$fp = fopen($arquivo, "r")){
|
||||
$contents = fread($fp, filesize($arquivo));
|
||||
fclose($fp);
|
||||
echo"$contents";
|
||||
}else{
|
||||
echo"<p class='verm'>Nome não encontrado! </p>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($reg != null){
|
||||
$arquivo = $reg.".txt";
|
||||
if(@$fp = fopen($arquivo, "r")){
|
||||
$contents = fread($fp, filesize($arquivo));
|
||||
fclose($fp);
|
||||
echo"$contents";
|
||||
}else{
|
||||
echo"<p class='verm'>Registro não encontrado! </p>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</main>
|
||||
<footer><h1>Programação WEB II - Prof. James Willian</h1></footer>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user