-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculadoraPOST.php
103 lines (89 loc) · 3.94 KB
/
calculadoraPOST.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
$operando1 = (isset($_POST['operando1'])) ? $_POST['operando1'] : 0;
$operando2 = (isset($_POST['operando2'])) ? $_POST['operando2'] : 0;
if (isset($_POST['operador'])) {
switch ($_POST['operador']) {
case 'mas':
$resultado = $operando1 + $operando2;
$operador = " + ";
break;
case 'menos':
$resultado = $operando1 - $operando2;
$operador = " - ";
break;
case 'por':
$resultado = $operando1 * $operando2;
$operador = " * ";
break;
case 'entre':
$resultado = $operando1 / $operando2;
$operador = " / ";
break;
}
}
else {
$operador = '+';
$resultado = $operando1 + $operando2;
}
?>
<!DOCTYPE HTML>
<!--
Identity by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Identity by HTML5 UP</title>
<meta charset="utf-8" />
<meta name="Referrer" content="no-referrer" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="https://html5up.net/uploads/demos/identity/assets/css/main.css" />
<noscript><link rel="stylesheet" href="https://html5up.net/uploads/demos/identity/assets/css/noscript.css" /></noscript>
</head>
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper">
<!-- Main -->
<section id="main">
<header>
<span class="avatar"><img src="https://es.calcuworld.com/wp-content/uploads/sites/2/2013/02/matematicas-150x150.png" alt="" /></span>
<h2>Calculadora Básica</h2>
<form name="calculator" action="" method="post">
<!-- Escribe el resultado como valor de la propiedad value -->
<input type="textfield" name="ans" value="<?php echo $operando1?> <?php echo $operador ?> <?php echo $operando2 ?> = <?php echo $resultado?>">
<br>
<input type="text" name="operando1" value="" placeholder="Operando 1">
<select name="operador">
<option value="mas">+</option>
<option value="menos">-</option>
<option value="por">*</option>
<option value="entre">/</option>
</select>
<input type="text" name="operando2" value="" placeholder="Operando 2">
<input type="submit" value="Calcular">
<input type="reset" value="Cancelar">
</form>
</header>
<footer>
<ul class="icons">
</ul>
</footer>
</section>
<!-- Footer -->
<footer id="footer">
<ul class="copyright">
<li>© Jane Doe</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
</ul>
</footer>
</div>
<!-- Scripts -->
<script>
if ('addEventListener' in window) {
window.addEventListener('load', function() { document.body.className = document.body.className.replace(/\bis-preload\b/, ''); });
document.body.className += (navigator.userAgent.match(/(MSIE|rv:11\.0)/) ? ' is-ie' : '');
}
</script>
</body>
</html>
<!-- Documento HTML-->