Skip to content
Open

Uf1 #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
26 changes: 26 additions & 0 deletions Trivia mejora Uf1/data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

$preguntas = [
[
'id' => 1,
'question' => '¿Cuál es la capital de Francia?',
'options' => ['París', 'Londres', 'Berlín'],
'answer' => 'París'
],
[
'id' => 2,
'question' => '¿Cuánto es 2 + 2?',
'options' => ['3', '4', '5'],
'answer' => '4'
],
[
'id' => 3,
'question' => '¿Cuál es la capital de Italia?',
'options' => ['Roma', 'Madrid', 'Vienna'],
'answer' => 'Roma'
]


]

?>
Empty file.
16 changes: 16 additions & 0 deletions Trivia mejora Uf1/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
<a href="manage.php" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
<svg class="bi me-2" width="40" height="32">
<use xlink:href="#bootstrap" />
</svg>
<i class="fa-solid fa-gear fs-4"></i>
</a>

<ul class="nav nav-pills">
<li class="nav-item"><a href="#" class="nav-link active" aria-current="page">Home</a></li>
<li class="nav-item"><a href="#" class="nav-link">Features</a></li>
<li class="nav-item"><a href="#" class="nav-link">Pricing</a></li>
<li class="nav-item"><a href="#" class="nav-link">FAQs</a></li>
<li class="nav-item"><a href="#" class="nav-link">About</a></li>
</ul>
</header>
19 changes: 19 additions & 0 deletions Trivia mejora Uf1/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inicio</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://kit.fontawesome.com/147cf78807.js" crossorigin="anonymous"></script>
</head>

<body>
<?php include "header.php" ?>

<h1>Hola quieres jugar</h1>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>

</html>
66 changes: 66 additions & 0 deletions Trivia mejora Uf1/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

session_start();

$usuarios = [
[
"username" => "admin",
"password" => 1234,
"rol" => "administrador"

],

[
"username" => "player",
"password" => 5678,
"rol" => "jugador"
]

];

if (isset($_POST['username']) && isset($_POST['password'])) {


foreach ($usuarios as $usuario) {
if ($usuario["username"] == $_POST['username'] && $usuario["password"] == $_POST['password']) {

$_SESSION['username'] = $usuario["username"];
$_SESSION['rol'] = $usuario["rol"];
if ($_SESSION['rol'] == 'administrador') {
header("Location: manage.php");
exit;
} else if ($_SESSION['rol'] == 'jugador') {
header("Location: trivial.php");
exit;
}
}
}
}

?>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Logueate</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://kit.fontawesome.com/147cf78807.js" crossorigin="anonymous"></script>
</head>

<body>
<?php include "header.php"?>

<form action="" method="POST">
<label for="form-label">Usuario</label>
<input type="text" name="username" class="form-control">
<label for="form-label">Contraseña</label>
<input type="text" name="password" class="form-control">
<button type="submit" class="btn btn-secondary">Iniciar Session</button>

</form>

</body>

</html>
14 changes: 14 additions & 0 deletions Trivia mejora Uf1/logout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

session_start();

if(isset($_GET['validar'])){
if($_GET['validar']){
session_destroy();
header('location: login.php');
exit;
}

}

?>
47 changes: 47 additions & 0 deletions Trivia mejora Uf1/manage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
session_start();
include "data.php";
if (isset($_SESSION['username']) && isset($_SESSION['rol'])) {
if ($_SESSION['username'] == 'admin' && $_SESSION['rol'] == 'administrador') {
}else{
header('Location: login.php');
exit;
}

}

?>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>

<body>
<?php
echo "Bienvenido " . $_SESSION['username'];

foreach ($preguntas as $pregunta) {
echo "<h2>" . $pregunta['question'] . "</h2>";
echo "<ul>";
foreach ($pregunta['options'] as $option) {
echo "<li>" . $option . "</li>";
}
echo "</ul>";

}
?>
<a class="btn btn-primary">Añadir nueva pregunta</a>
<a class="btn btn-succes">Editar pregunta</a>

<a class="btn btn-danger">Borrar pregunta</a>

<a href="logout.php?validar=true" class="btn btn-danger">Cerrar Session</a>

</body>

</html>
Empty file added Trivia mejora Uf1/styles.css
Empty file.
78 changes: 78 additions & 0 deletions Trivia mejora Uf1/trivial.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
session_start();

if (isset($_SESSION['username']) && isset($_SESSION['rol'])) {
if ($_SESSION['username'] == 'player' && $_SESSION['rol'] == 'jugador') {
}
}
include "data.php";

$preguntas = [
[
'id' => 1,
'question' => '¿Cuál es la capital de Francia?',
'options' => ['París', 'Londres', 'Berlín'],
'answer' => 'París'
],
[
'id' => 2,
'question' => '¿Cuánto es 2 + 2?',
'options' => ['3', '4', '5'],
'answer' => '4'
],
[
'id' => 3,
'question' => '¿Cuál es la capital de Italia?',
'options' => ['Roma', 'Madrid', 'Vienna'],
'answer' => 'Roma'
]
];

$contador = isset($_SESSION['contador']) ? $_SESSION['contador'] : 0;
$mensajedemal = '';

if (isset($_POST['respuesta'])) {
if ($_POST['respuesta'] == $preguntas[$contador]['answer']) {
$contador++;
if ($contador > count($preguntas) - 1) {
$contador = 0;
}
$_SESSION['contador'] = $contador;
header("location: trivial.php");
} else {
$mensajedemal = "Incorrecto, intenta de nuevo";
}
}

$pregunta = $preguntas[$contador]['question'];
$alternativa1 = $preguntas[$contador]['options'][0];
$alternativa2 = $preguntas[$contador]['options'][1];
$alternativa3 = $preguntas[$contador]['options'][2];
?>
<!DOCTYPE html>
<html lang="es">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Trivia</title>

</head>

<body>
<h1>Bienvenido a la trivia</h1>
<form action="" method="post">
<h3><?= $pregunta ?></h3>
<input type="radio" name="respuesta" value="<?php echo $alternativa1; ?>">
<label for="respuestas"><?= $alternativa1 ?></label>
<input type="radio" name="respuesta" value="<?php echo $alternativa2; ?>">
<label for="respuestas"><?= $alternativa2 ?></label>
<input type="radio" name="respuesta" value="<?php echo $alternativa3; ?>">
<label for="respuestas"><?= $alternativa3 ?></label>

<button type="submit" class="btn btn-primary">Verificar</button>
<?= $mensajedemal ?>
</form>
</body>

</html>
89 changes: 89 additions & 0 deletions cajafuerte/bienvenida.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html lang="ca">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Benvingut a la teva casa de Hogwarts</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<?php

// Array multidimensional amb la informació de cada casa
$casas_info = [
"Gryffindor" => [
"background_color" => "#740001",
"text_color" => "#FFD700",
"welcome_message" => "Coratge, valor i determinació. Benvingut a Gryffindor!",
"message_background" => "#D3A625",
"image" => "https://static.wikia.nocookie.net/esharrypotter/images/a/a3/Gryffindor_Pottermore.png/revision/latest?cb=20140922195249"
],
"Hufflepuff" => [
"background_color" => "#FFDB00",
"text_color" => "#60605B",
"welcome_message" => "Lleialtat, paciència i treball dur. Benvingut a Hufflepuff!",
"message_background" => "#EEE117",
"image" => "https://static.wikia.nocookie.net/esharrypotter/images/3/30/Logo_Hufflepuff_2.png/revision/latest/scale-to-width-down/250?cb=20160417160852"
],
"Ravenclaw" => [
"background_color" => "#0E1A40",
"text_color" => "#946B2D",
"welcome_message" => "Intel·ligència, creativitat i saviesa. Benvingut a Ravenclaw!",
"message_background" => "#5D5D5D",
"image" => "https://static.wikia.nocookie.net/esharrypotter/images/7/76/Ravenclaw_Pottermore.png/revision/latest?cb=20141001130914"
],
"Slytherin" => [
"background_color" => "#1A472A",
"text_color" => "#AAAAAA",
"welcome_message" => "Ambició, astúcia i lideratge. Benvingut a Slytherin!",
"message_background" => "#5D5D5D",
"image" => "https://static.wikia.nocookie.net/esharrypotter/images/6/69/Slytherin_Pottermore.png/revision/latest/thumbnail/width/360/height/360?cb=20141001130915"
]
];
$nombre =$_POST['nombre'];
$apellidos =$_POST['Apellidos'];

$casas = array_keys($casas_info);
$casaseleccionada = $casas[array_rand($casas)];



?>
<style>
body{
background-color: <?php echo $casas_info[$casaseleccionada]['background_color']?> ;
}
.mensajebienvenida{
background-color: <?php echo $casas_info[$casaseleccionada]['message_background']?>;
}
h1,h4,h6{
color: <?php echo $casas_info[$casaseleccionada]['text_color']?>;
}

</style>
</head>
<body>

<div class="container text-center">
<?php


echo "<h1>¡Benvingut a " . $casaseleccionada ."!</h1>";

echo "<div class='mensajebienvenida'>";
echo "<h4 >¡" . $nombre . " ". $apellidos . " has sido seleccionado para ". $casaseleccionada . "!</h4>";
echo "<h6>". $casas_info[$casaseleccionada]['welcome_message']."</h6>";

?>
<img src="<?php echo $casas_info[$casaseleccionada]['image']?>" alt="" style="width: 400px; height: 380px; margin: 0 0 30px 0;">


</div>
</div>
</body>
<style>
<?php


?>
</style>
</html>
25 changes: 25 additions & 0 deletions cajafuerte/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="ca">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sombrero Seleccionador de Hogwarts</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<?php

?>
<body>
<div class="container">
<h1 class="text-center mb-4">Bienvenido a Hogwarts</h1>
<h4 class="text-center mb-4">Por favor ingrese sus Datos</h4>
<form action="bienvenida.php" method="POST">
<label for="nombre">Nombre: </label>
<input type="text" name="nombre">
<label for="apellidos">Apellidos: </label>
<input type="text" name="Apellidos">
<button type="submit">Registrar</button>
</form>
</div>
</body>
</html>
Empty file added examen 2 M7/array.php
Empty file.
Loading