-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathej5.php
58 lines (46 loc) · 1.11 KB
/
ej5.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
session_start();
$_SESSION["username"]="usuario";
$contenidosession = "";
function agregarsession($dato){
return "As contenido: " . $dato;
}
function eliminarsession($dato){
return "Es contenido: " . $dato;
}
if(!isset($_SESSION["click"])){
$_SESSION["click"]=0;
}
if(isset($_POST["btnadd"])){
$contenidosession .= agregarsession($_POST["txtdata"]);
$_SESSION["click"] ++;
}
if(isset($_POST["btnsubs"])){
$contenidosession = eliminarsession($_POST["txtdata"]);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Funciones y session</title>
</head>
<body>
<h1>Funciones y el arreglo session</h1>
<form action="ej5.php" method="post">
<label for="txtdata">data</label>
<input type="text" id="txtdata"
name="txtdata" />
<br/>
<input type="submit" name="btnadd"
id="btnadd" value="agregar a la sesion" />
<input type="submit" name="btnsubs"
id="btnsubs" value="Eliminar de la sesion">
</form>
<div>
<?php
echo $contenidosession;
?>
</div>
</body>
</html>