<!DOCTYPE html> <html lang="cs-cz"> <head> <meta chartset="utf-8" /> <meta name="vievport" content="width=device-width, initial-scale=1.0" /> <title>PHP Kalkulačka 25.7.2024 David Tomek I3 unixuser@seznam.cz</title> <style> table{ border:2px solid green; width:30%; padding:10px; background-color:lightgray; } input{ background-color:lightblue; margin-bottom:10px; width:"auto"; } footer{ background-color:lightgray; border:2px solid green; padding:10px; margin-top:10px; width:30%; font-size:8px; } label{ background-color:#9dadc7; border:2px solid #718f76; } body{ background-color:#9eb5b8; } </style> </head> <body> <?php $cislo1=$cislo2=0; $vysledek=0; // echo $vysledek; if(isset($_POST["secti"])){ $cislo1=(float)$_POST['cislo1I']; $cislo2=(float)$_POST['cislo2I']; $vysledek=$cislo1+$cislo2; } if(isset($_POST["odecti"])){ $cislo1=(float)$_POST['cislo1I']; $cislo2=(float)$_POST['cislo2I']; $vysledek=$cislo1-$cislo2; } if(isset($_POST["vynasob"])){ $cislo1=(float)$_POST['cislo1I']; $cislo2=(float)$_POST['cislo2I']; $vysledek=$cislo1*$cislo2; } if(isset($_POST["vydel"])){ $cislo1=(float)$_POST['cislo1I']; $cislo2=(float)$_POST['cislo2I']; if($cislo2!=0) $vysledek=$cislo1/$cislo2; else $vysledek="Chyba dělení nulou !"; } ?> <form method="post" action=""> <table> <tr> <td><label>První číslo</label></td> <td><input type="text" name="cislo1I" value="<?php echo $cislo1;?>"/></td> </tr> <tr> <td><label>Druhé číslo</label></td> <td><input type="text" name="cislo2I" value="<?php echo $cislo2;?>" /></td> </tr> <tr> <td><label>Výsledek</label></td> <td><input type="text" name="vysledekI" value="<?php echo $vysledek;?>" /></td> </tr> <tr> <td><label>Matematická operace</label></td> </tr> <tr> <td><label>Sečti</label></td> <td><input type="submit" name="secti" value="+" /></td> </tr> <tr> <td><label>Odečti</label></td> <td><input type="submit" name="odecti" value="-" /></td> </tr> <tr> <td><label>Vynásob</label></td> <td><input type="submit" name="vynasob" value="*" /></td> </tr> <tr> <td><label>Vyděl</label></td> <td><input type="submit" name="vydel" value="/" /></td> </tr> <tr> <td>PHP Kalkulačka 25.7.2024 David Tomek I3</td> </tr> <tr> <td><a href=mailto:"unixuser@seznam.cz">unixuser@seznam.cz</a></td> </tr> <tr> <td><a href="https://home.spsostrov.cz/~tomeda/">https://home.spsostrov.cz/~tomeda/</td> </tr> </table> </form> </table> </body> </html>