Temat: PHP + form + text + check + select
<?php
if (isset($_POST['t1'])) $t1 = (int)$_POST['t1']; else $t1 = 0;
if (isset($_POST['t2'])) $t2 = (int)$_POST['t2']; else $t2 = 0;
if (isset($_POST['s'])) $s = (int)$_POST['s']; else $s = 0;
if (isset($_POST['c'])) $c = (int)$_POST['c']; else $c = 0;
?>
<form action="" method="post">
liczba 1 <input type="text" name="t1" value="<?=$t1; ?>"><br>
liczba 2 <input type="text" name="t2" value="<?=$t2; ?>"><br>
operacja <select name="s">
<option value="1" <?php if ($s == 1) echo "selected" ?>>+</option>
<option value="2" <?php if ($s == 2) echo "selected" ?>>-</option>
</select><br>
+1 <input type="checkbox" name="c" value="1" <?php if ($c == 1) echo "checked" ?>><br>
<input type="submit" value="ok">
</form>
<?php
if ($_POST)
{
if ($s == 1) echo "<h1>".($t1+$t2+$c)."</h1>";
if ($s == 2) echo "<h1>".($t1-$t2+$c)."</h1>";
}
?>