Está en la página 1de 6

ACTIVIDAD 3:

CODIGO:
<?php
require_once "funcion.php";
session_start();
if (isset($_POST["accion"]) && $_POST["accion"] == "cerrar_sesion") {
session_destroy();
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,
initialscale=1.0">
<title>Document</title>
</head>
<body>
<h1>LOGIN</h1>
<form action="" method="post">
<label for="nombre">Nombre</label>
<input type="text" name="nombre"><br>
<label for="contraseña">Contraseña</label>
<input type="password" name="contraseña" id=""><br>
<input type="submit" value="Enviar">
</form>
</body>
</html>
CODIGO:
<?php
$usuario = array(
array(1, "luis", "12345", 1 ),
array(2, "jose", "luis", 2 ),
);
if(isset($_POST["nombre"]) && isset($_POST["contraseña"])){
foreach($usuario as $valor){
$id = $valor[0];
$nombre = $valor[1];
$password = $valor[2];
$tipoUsuario = $valor[3];
if($_POST["nombre"] == $nombre && $_POST["contraseña"] ==
$password){
session_start();
$_SESSION["newSession"] = array(
"id" => $id,
"nombre" => $nombre,
"password" => $password,
"tipoUsuario" => $tipoUsuario,
);
if($valor[3] == 1){
header('Location: imc.php');
}elseif($valor[3] ==2){
header('Location: covid.php');
}
}
}
echo "USUARIO Y/O CONTRASEÑA INCORRECTA";
}
?>
CODIGO:
<?php
include "funcion.php";
session_start();
if(isset($_SESSION["newSession"])){
$nSession = "Bienvenido ".$_SESSION["newSession"]["nombre"];
}else{
header('Location: index.php');
}
if($_POST){
if(isset($_POST["tos"]) && isset($_POST["fiebre"]) &&
isset($_POST["dificultadRespiratoria"])) {
$tos = $_POST["tos"];
$fiebre = $_POST["fiebre"];
$dificultadRespiratoria = $_POST["dificultadRespiratoria"];
$msg = "Es posible que tengas COVID 19";
}else{ $msg = "Es poco probable que tengas COVID 19"; }
}
?>
<!DOCTYPE html>
<head>
<title>Document</title>
</head>
<body>
<?php echo isset($nSession) ? $nSession: "";?>
<h1>DIAGNOSTICO DE COVID</h1>
<h3>Seleccione todos los sintomas que tiene</h3>
<form action="" method="post">
<input type="checkbox" name="tos" id="">Tos <br>
<input type="checkbox" name="fiebre" id="">Fiebre <br>
<input type="checkbox" name="dificultadRespiratoria" id="">dificultad
Respiratoria <br><br>
<input type="submit" value="Enviar">
</form>
<?php echo isset($msg) ? $msg : "";?><br><br>
<form action="index.php" method="post">
<input type="submit" value="Cerrar Session">
</form>
</body>
</html>

CODIGO:
<?php
require_once "funcion.php";
session_start();
if(isset($_SESSION["newSession"])){
$nombreEnSession = "Bienvenido ".$_SESSION["newSession"]["nombre"];
}else{ header('Location: index.php'); }
function calcularIMC($peso, $altura){
return round($peso / ($altura * 2),2);
}
if(isset($_POST["peso"]) && isset($_POST["altura"])){
$peso = $_POST["peso"];
$altura = $_POST["altura"];
$imc = calcularIMC($peso, $altura);
if($imc < 18.5){
$textImc = "Tu Indice de Masa Corporal es $imc por lo tanto es
bajo peso";
}elseif($imc >= 18.5 && $imc < 25){
$textImc = "Tu Indice de Masa Corporal es $imc por lo tanto es
normal";
}elseif($imc >= 25 && $imc < 30){
$textImc = "Tu Indice de Masa Corporal es $imc por lo tanto es
Sobrepeso";
}elseif($imc >= 30 && $imc < 35){
$textImc = "Tu Indice de Masa Corporal es $imc por lo tanto es
Obesidad1";
}elseif($imc >= 35 && $imc < 40){
$textImc = "Tu Indice de Masa Corporal es $imc por lo tanto es
Obesidad2";
}elseif($imc >= 40){
$textImc = "Tu Indice de Masa Corporal es $imc por lo tanto es
Obesidad3";
}else{ echo "Los datos ingresados son incorrectos"; }
}
?>
<!DOCTYPE html>
<head>
<title>IMC</title>
</head>
<body>
<?php echo isset($nombreEnSession) ? $nombreEnSession : "";?>
<h1>IMC</h1>
<form action="" method="post">
<label for="">Peso en KG</label>
<input type="number" name="peso" id=""><br>
<label for="">Altura en metros</label>
<input type="number" step="any" name="altura" id="">
<input type="submit" value="Calcular">
</form>
<form action="index.php" method="post">
<input type="submit" value="Cerrar Session">
</form>
<?php echo isset($textImc) ? $textImc : ""; ?>
</body>
</html>

También podría gustarte