-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath.php
69 lines (56 loc) · 1.73 KB
/
math.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sending form data</title>
</head>
<body>
<form action="index.php" method="post">
<label for="quantity">x: </label>
<input type="text" name="quantity" id="quantity"><br /><br />
<label for="y">y: </label>
<input type="text" name="y" id="y"><br /><br />
<label for="y">z: </label>
<input type="text" name="z" id="z"><br /><br />
<!-- <label for="quantity">quantity: </label>
<input type="text" name="quantity" id="quantity"><br /><br /> -->
<!-- <label for="password">password: </label>
<input type="password" name="password" id="password"><br /><br /> -->
<input type="submit" name="total" id="total"><br /><br />
<!-- <button type="submit">Submit</button> -->
</form>
</body>
</html>
<?php
// echo $_GET["username"] . "<br/>";
// echo "{$_GET["username"]} <br/>";
// echo "{$_GET["password"]} <br/>";
// echo "{$_POST["quantity"]} <br/>";
// echo "{$_POST["password"]} <br/>";
// $item = "pizza";
// $price = 5.99;
// $quantity = $_POST["quantity"];
// $total = null;
// $total = $quantity * $price;
// echo "You have ordered {$quantity} x {$item}/s <br/>";
// echo "Your total is \${$total}";
// math functions
$x = $_POST["quantity"];
$y = $_POST["y"];
$z = $_POST["z"];
$total = null;
// absolute function
// $total = abs($x);
// $total = round($x);
// $total = round($x, 2);
// $total = ceil($x);
// $total = pow($x, $y);
// $total = sqrt($x);
// $total = max($x, $y, $z);
// $total = min($x, $y, $z);
// $total = pi();
// $total = rand();
$total = rand(1, 6); //including 1 and 6
echo $total
?>