Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $tehteLiik = "Puudub";
- $arv1 = 0;
- $arv2 = 0;
- if( Olemas( $_POST[ 'arv1' ] ) && Olemas( $_POST[ 'arv2' ] ) )
- {
- $arv1 = $_POST[ 'arv1' ];
- $arv2 = $_POST[ 'arv2' ];
- }
- if( Olemas( $_POST[ 'tehe' ] ) )
- {
- $tehteLiik = $_POST[ 'tehe' ];
- switch( $tehteLiik )
- {
- case "Liida":
- {
- $vastus = Liida( $arv1, $arv2 );
- }
- break;
- case "Lahuta":
- {
- $vastus = Lahuta( $arv1, $arv2 );
- }
- break;
- case "Korruta":
- {
- $vastus = Korruta( $arv1, $arv2 );
- }
- break;
- case "Jaga":
- {
- $vastus = Jaga( $arv1, $arv2 );
- }
- break;
- }
- $html = '<h2>Tehte vastus: </h2><br />' . $vastus . '';
- }
- function Liida( $arv1, $arv2 )
- {
- return $arv1 + $arv2;
- }
- function Lahuta( $arv1, $arv2 )
- {
- return $arv1 - $arv2;
- }
- function Korruta( $arv1, $arv2 )
- {
- return $arv1 * $arv2;
- }
- function Jaga( $arv1, $arv2 )
- {
- return $arv1 / $arv2;
- }
- function Olemas( $parameeter )
- {
- if( isset( $parameeter ) )
- return true;
- else
- return false;
- }
- ?>
- <html>
- <head>
- <title>Programmeerimine - Tehted</title>
- </head>
- <body>
- <div id="container">
- <form>
- <label for="arv1">Esimene arv</label>
- <input type="text" name="arv1" />
- <label for="arv2">Teine arv</label>
- <input type="text" name="arv2" />
- <label for="tehe">Liida</label>
- <input type="radio" name="tehe" value="Liida" />
- <label for="tehe">Korruta</label>
- <input type="radio" name="tehe" value="Korruta" />
- <label for="tehe">Jaga</label>
- <input type="radio" name="tehe" value="Jaga" />
- </form>
- <p>
- <?php echo $html; ?>
- </p>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment