Skip to content

Commit 103d10a

Browse files
author
julieta.martinez
committed
clase15
1 parent a41539b commit 103d10a

File tree

218 files changed

+17263
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+17263
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
if(isset($_COOKIE['contador']))
3+
{
4+
// Caduca en un año
5+
setcookie('contador', $_COOKIE['contador'] + 1, time() + 365 * 24 * 60 * 60);
6+
$mensaje = 'Número de visitas: ' . $_COOKIE['contador'];
7+
}
8+
else
9+
{
10+
// Caduca en un año
11+
setcookie('contador', 1, time() + 365 * 24 * 60 * 60);
12+
$mensaje = 'Bienvenido a nuestra página web';
13+
}
14+
?>
15+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
16+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
17+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
18+
<head>
19+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
20+
<title>Prueba de cookie</title>
21+
</head>
22+
<body>
23+
<p>
24+
<?php echo $mensaje; ?>
25+
</p>
26+
</body>
27+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
session_start();
3+
if(!empty($_SESSION['usuario'])){
4+
/* La funcion empty() devuelve verdadero si el argumento posee un valor vacio,
5+
al usar !empty() devuelve verdadero no solo si la variable fue declarada sino
6+
ademas si contiene algun valor no nulo.
7+
*/
8+
echo 'Te haz logueado como: '.$_SESSION['usuario'].'<br />';
9+
echo 'Haz logrado el acceso a una pagina segura';
10+
}else{
11+
echo 'No estas logueado<br />';
12+
echo 'Esta pagina es restringida!';
13+
}
14+
?>
15+
<a href="login.php">BACK TO LOGIN</a>
16+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
<?php
3+
session_start();
4+
?>
5+
<html>
6+
<head>
7+
<title>Las sesiones</title>
8+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9+
</head>
10+
<body>
11+
<?php
12+
if(isset($_POST['enviar'])){
13+
if(empty($_POST['usuario']) || empty($_POST['password']))
14+
echo 'Debes llenar todos los datos';
15+
elseif($_POST['usuario']=="test" and $_POST['password']=="test"){
16+
$_SESSION['usuario']=$_POST['usuario'];
17+
$_SESSION['password']=$_POST['password'];
18+
echo 'Logueado como '.$_SESSION['usuario'];
19+
}
20+
}
21+
?>
22+
<form name="login" method="post" action="login.php">
23+
<p> Usuario: <input name="usuario" type="text" id="usuario"> </p>
24+
<p>Password: <input name="password" type="password" id="password"></p>
25+
<input name="enviar" type="submit" id="enviar" value="Enviar">
26+
</form>
27+
<p> si entras como test/test, te logueará y podras ver el link de abajo.</p>
28+
<a href="logedpage.php">IR A PAGINA RESTRINGIDA</a>
29+
</body>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
session_start ();
3+
if(!empty($_SESSION['usuario']))
4+
{
5+
session_destroy ();
6+
echo "Sesión finalizada";
7+
}
8+
?>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
session_start();
3+
4+
if(isset($_SESSION['contador']))
5+
{
6+
$_SESSION['contador'] = $_SESSION['contador'] + 1;
7+
$mensaje = 'Número de visitas: ' . $_SESSION['contador'];
8+
}
9+
else
10+
{
11+
$_SESSION['contador'] = 1;
12+
$mensaje = 'Bienvenido a nuestra página web';
13+
}
14+
?>
15+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
16+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
17+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
18+
<head>
19+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
20+
<title>Prueba de cookie</title>
21+
</head>
22+
<body>
23+
<p>
24+
<?php echo $mensaje; ?>
25+
</p>
26+
</body>
27+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
session_start();
3+
echo 'session_id(): ' . session_id();
4+
echo "<br />\n";
5+
echo 'session_name(): ' . session_name();
6+
echo "<br />\n";
7+
?>

Marcos/Clase15/ejemploCrud/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE TABLE `clase15`.`users` (
2+
`id` INT NOT NULL AUTO_INCREMENT,
3+
`name` VARCHAR(45) NOT NULL,
4+
`email` VARCHAR(45) NOT NULL,
5+
`sexo` ENUM('F', 'M', 'N') NOT NULL,
6+
PRIMARY KEY (`id`));
7+
8+
CREATE TABLE `clase15`.`pets` (
9+
`id` INT NOT NULL AUTO_INCREMENT,
10+
`race` VARCHAR(45) NOT NULL,
11+
`name` VARCHAR(45) NOT NULL,
12+
`sexo` ENUM('F', 'M', 'N') NOT NULL,
13+
PRIMARY KEY (`id`));
14+
15+
ALTER TABLE `clase15`.`pets` ADD COLUMN `user_id` INT NULL AFTER `id`;
16+
ALTER TABLE `clase15`.`pets` ADD FOREIGN KEY(`user_id`)
17+
REFERENCES `users`(`id`);
18+
19+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
INSERT INTO `clase15`.`users` (`name`, `email`, `sexo`) VALUES ('mari', 'mari@fakemails', 'F');
2+
INSERT INTO `clase15`.`users` (`name`, `email`, `sexo`) VALUES ('rosa', '[email protected]', 'F');
3+
INSERT INTO `clase15`.`users` (`name`, `email`, `sexo`) VALUES ('luis', '[email protected]', 'M');
4+
INSERT INTO `clase15`.`users` (`name`, `email`, `sexo`) VALUES ('komai', '[email protected]', 'N');
5+
INSERT INTO `clase15`.`users` (`name`, `email`, `sexo`) VALUES ('mario', '[email protected]', 'M');
6+
INSERT INTO `clase15`.`users` (`name`, `email`, `sexo`) VALUES ('paqui', '[email protected]', 'F');
7+
INSERT INTO `clase15`.`users` (`name`, `email`, `sexo`) VALUES ('antonio', '[email protected]', 'M');
8+
9+
INSERT INTO `clase15`.`pets` (`race`, `name`, `sexo`) VALUES ('cat', 'pet-mari', 'F');
10+
INSERT INTO `clase15`.`pets` (`race`, `name`, `sexo`) VALUES ('cat', 'pet-rosa', 'F');
11+
INSERT INTO `clase15`.`pets` (`race`, `name`, `sexo`) VALUES ('cat', 'pet-luis', 'M');
12+
INSERT INTO `clase15`.`pets` (`race`, `name`, `sexo`) VALUES ('cat', 'pet-komai', 'N');
13+
INSERT INTO `clase15`.`pets` (`race`, `name`, `sexo`) VALUES ('cat', 'pet-mario', 'M');
14+
INSERT INTO `clase15`.`pets` (`race`, `name`, `sexo`) VALUES ('cat', 'pet-paqui', 'F');
15+
INSERT INTO `clase15`.`pets` (`race`, `name`, `sexo`) VALUES ('cat', 'pet-antonio', 'M');
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# ./docker-compose.yml
2+
3+
version: '3'
4+
5+
services:
6+
db:
7+
image: mysql:5.7
8+
container_name: mysql_db_C15
9+
environment:
10+
MYSQL_ROOT_PASSWORD: rootsecretpass
11+
MYSQL_DATABASE: clase15
12+
MYSQL_USER: devuser
13+
MYSQL_PASSWORD: devpass
14+
ports:
15+
- "9906:3306"
16+
web:
17+
build:
18+
context: ./docker/php
19+
container_name: php_web_C15
20+
depends_on:
21+
- db
22+
volumes:
23+
- ./php/:/var/www/html/
24+
ports:
25+
- "8100:80"
26+
tty: true
27+

0 commit comments

Comments
 (0)