Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta charset="UTF-8">
- </head>
- <body>
- <?php
- if (isset($_GET['N1'])){
- $a = ($_GET['N1']);
- }
- if (isset($_GET['N2'])) {
- $b = ($_GET['N2']);
- }
- ?>
- <form >
- Number 1: <input type="text" name="N1" value="<?php
- if (isset($_GET['N1'])){
- echo ($_GET['N1']);
- } ?>" > <br>
- Number 2: <input type="text" name="N2" value="<?php if (isset($_GET['N2'])) {
- echo ($_GET['N2']);
- } ?>"> <br>
- <hr>
- <input type="radio" name="Operation" value="+"> + <br>
- <input type="radio" name="Operation" value="-"> - <br>
- <input type="radio" name="Operation" value="*"> * <br>
- <input type="radio" name="Operation" value="/"> / <br>
- <hr>
- <br> <input type="submit" name="submit" value="="> <br>
- <?php
- switch( $_GET['Operation'] ) {
- case '+':
- echo $a + $b ;
- break;
- case '-' :
- echo $a - $b ;
- break;
- case '*':
- echo $a * $b ;
- break;
- case '/' :
- if ($b == 0) {
- echo 'error';
- }
- else {
- echo $a / $b ;
- }
- break;
- }
- ?>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement