Tuqum

 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
<html>
<title>Amallar bajarish</title>
<body>
<?php
$natija = '';
if (isset($_POST['ok'])) {
if (in_array($_POST['amal'], array('+', '-', '*', '/'))) {
$a = $_POST['a'];
$b = $_POST['b'];
if ($_POST['amal'] == '+') {
$natija = "$a + $b = " . $a + $b;
} elseif ($_POST['amal'] == '-') {
$natija = "$a - $b = " . $a - $b;
} elseif ($_POST['amal'] == '*') {
$natija = "$a * $b = " . $a * $b;
} elseif ($_POST['amal'] == '/') {
if ($b) {
$natija = "$a / $b = " . $a / $b;
} else {
$natija = 'Ulug‘bekning tuqumiga bo‘lib bo‘lmaydi!';
}
}
} else {
$natija = 'Amalni to‘g‘ri kirit, bo‘lmasa, orqang 6 ga bo‘linadi!';
}
}
?>
<?php if (!empty($natija)) : ?>
<p style="color: #ff0000"><?php echo $natija; ?></p>
<?php endif; ?>
<form action="#" method="POST">
<input type="text" name="a" size="4" />&nbsp;
<select name="amal">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>&nbsp;
<input type="text" name="b" size="4" />&nbsp;
<input type="submit" name="ok" value="=" />
</form>
</body>
</html>