if isset _POST ok if _POST amal _POST amal _POST amal _POST amal echo

 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
<?
if (isset($_POST["ok"]))
{
if (($_POST["amal"]!="-") || ($_POST["amal"]!="+") || ($_POST["amal"]!="*") || ($_POST["amal"]!="/"))
{
echo "Amal xato kiritilgan";
exit;
}
if ($_POST["amal"]=="+") {
echo $a+$b;
exit;
}
if ($_POST["amal"]=="*") {
echo $a*$b;
exit;
}
if ($_POST["amal"]=="-") {
echo $a-$b;
exit;
}
if ($_POST["amal"]=="/") {
$d=$a/$b;
if ($b==0)
{
echo "Nolga bo'linish yuz berdi";
exit;
}
else
echo $d;
exit;
}
}
?>
<html>
<head>
<body>
<form action="amal.php" method="POST">
a:<input type="text" name="a"><br>
b:<input type="text" name="b"><br>
amal:<input type="text" name="amal"><br>
<input type="submit" name="ok" value="ok">
</form>
</body>
</head>
</html>