forked from obetancourthunicah/IF412NegociosWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha.php
57 lines (57 loc) · 1.48 KB
/
a.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
<?php
//para inicia la session
session_start();
function addNoCuenta($numCuenta){
$cuentas = array();
if(isset($_SESSION["Cuentas"])){
$cuentas = $_SESSION["Cuentas"];
}
$hasChanged= false;
foreach($cuentas as $cuenta => $contador){
if($cuenta == $numCuenta){
$contador ++;
$hasChanged = true;
$cuentas[$cuenta] = $contador;
}
}
if(!$hasChanged){
$cuentas[$numCuenta] = 1;
}
$_SESSION["Cuentas"] = $cuentas;
}
if(isset($_POST["btnAdd"])){
addNoCuenta($_POST["txt1"]);
addNoCuenta($_POST["txt2"]);
addNoCuenta($_POST["txt3"]);
addNoCuenta($_POST["txt4"]);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Ejemplo PHP Sessiones 2</title>
</head>
<body>
<h1>Ejercicio de Formulario Acumulado</h1>
<form action="a.php" method="POST" >
<label for="txt1">Cuenta 1</label>
<input type="text" name="txt1"
id="txt1" value="" /><br/>
<label for="txt2">Cuenta 2</label>
<input type="text" name="txt2"
id="txt2" value="" /><br/>
<label for="txt3">Cuenta 3</label>
<input type="text" name="txt3"
id="txt3" value="" /><br/>
<label for="txt4">Cuenta 4</label>
<input type="text" name="txt4"
id="txt4" value="" /><br/>
<input type="submit" name="btnAdd"
id="btnAdd" value="Agregar" />
</form>
<a href="b.php" target="_blank">
Ir a Ver Resultados
</a>
</body>
</html>