aulinha
This commit is contained in:
135
aula4.php
Normal file
135
aula4.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<!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 4 - Jogo (soma 15)</title>
|
||||
<link rel="stylesheet" href="estilo.css">
|
||||
<style>
|
||||
.resp{
|
||||
position: fixed;
|
||||
top: 20%;
|
||||
left:50%;
|
||||
font-size: 240%;
|
||||
}
|
||||
a:link {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:visited{
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header><h1>Aula 4 - Jogo (soma 15)</h1></header>
|
||||
<nav></nav>
|
||||
<main>
|
||||
<p>Prencha os nove campos com números de um a nove, <br>não repetindo nenhum número.</p>
|
||||
<p>A soma de cada linha, cada coluna e cada diagonal deve ser 15.</p>
|
||||
|
||||
<form action="aula4.php" method="POST">
|
||||
<input type="hidden" name="jogo" value="1">
|
||||
<table>
|
||||
<tr>
|
||||
<td><input type="text" name="a1" size="4"></td>
|
||||
<td><input type="text" name="b1" size="4"></td>
|
||||
<td><input type="text" name="c1" size="4"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" name="a2" size="4"></td>
|
||||
<td><input type="text" name="b2" size="4"></td>
|
||||
<td><input type="text" name="c2" size="4"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" name="a3" size="4"></td>
|
||||
<td><input type="text" name="b3" size="4"></td>
|
||||
<td><input type="text" name="c3" size="4"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="reset" value="Limpar"></td>
|
||||
<td><button><a href="aula4.php">Voltar</a></button></td>
|
||||
<td><input type="submit" name="Enviar"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<div class="resp">
|
||||
<?php
|
||||
if(isset($_POST["jogo"])){$jogo = $_POST["jogo"];}else{$jogo = null;}
|
||||
if(isset($_POST["a1"])){$a1 = $_POST["a1"];}else{$a1 = null;}
|
||||
if(isset($_POST["b1"])){$b1 = $_POST["b1"];}else{$b1 = null;}
|
||||
if(isset($_POST["c1"])){$c1 = $_POST["c1"];}else{$c1 = null;}
|
||||
if(isset($_POST["a2"])){$a2 = $_POST["a2"];}else{$a2 = null;}
|
||||
if(isset($_POST["b2"])){$b2 = $_POST["b2"];}else{$b2 = null;}
|
||||
if(isset($_POST["c2"])){$c2 = $_POST["c2"];}else{$c2 = null;}
|
||||
if(isset($_POST["a3"])){$a3 = $_POST["a3"];}else{$a3 = null;}
|
||||
if(isset($_POST["b3"])){$b3 = $_POST["b3"];}else{$b3 = null;}
|
||||
if(isset($_POST["c3"])){$c3 = $_POST["c3"];}else{$c3 = null;}
|
||||
|
||||
$er = 0;
|
||||
if($jogo == "1"){
|
||||
if($a1 == null or $b1 == null or $c1 == null or $a2 == null or $b2 == null or $c2 == null or $a3 == null or $b3 == null or $c3 == null){
|
||||
echo"<p class='verm'>Preencha todos os campos!</p>";
|
||||
}
|
||||
else{
|
||||
if(($a1 + $b1 + $c1) != 15){
|
||||
echo"<p class='verm'>Erro na linha 1!</p>";
|
||||
$er = 1;
|
||||
}
|
||||
if(($a2 + $b2 + $c2) != 15){
|
||||
echo"<p class='verm'>Erro na linha 2!</p>";
|
||||
$er = 1;
|
||||
}
|
||||
if(($a3 + $b3 + $c3) != 15){
|
||||
echo"<p class='verm'>Erro na linha 3!</p>";
|
||||
$er = 1;
|
||||
}
|
||||
|
||||
if(($a1 + $a2 + $a3) != 15){
|
||||
echo"<p class='verm'>Erro na coluna 1!</p>";
|
||||
$er = 1;
|
||||
}
|
||||
|
||||
if(($b1 + $b2 + $b3) != 15){
|
||||
echo"<p class='verm'>Erro na coluna 2!</p>";
|
||||
$er = 1;
|
||||
}
|
||||
|
||||
if(($c1 + $c2 + $c3) != 15){
|
||||
echo"<p class='verm'>Erro na coluna 3!</p>";
|
||||
$er = 1;
|
||||
}
|
||||
|
||||
if(($a1 + $b2 + $c3) != 15){
|
||||
echo"<p class='verm'>Erro na diagonal descendente!</p>";
|
||||
$er = 1;
|
||||
}
|
||||
|
||||
if(($a3 + $b2 + $c1) != 15){
|
||||
echo"<p class='verm'>Erro na diagonal ascendente!</p>";
|
||||
$er = 1;
|
||||
}
|
||||
|
||||
if($a1 == $a2){
|
||||
echo"<p class='verm'>Números repetidos!</p>";
|
||||
$er = 1;
|
||||
}
|
||||
|
||||
|
||||
if($er == 0){
|
||||
echo"<p class='verd'>Vencedor!!!</p>";
|
||||
echo"<p><button><a href='aula5.php'>Proximo Jogo</a></button></p>";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
</main>
|
||||
<footer><h1>Programação WEB II - Prof James Willian</h1></footer>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user