Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['cm']))
- {
- if(!is_numeric($_POST['cm']))
- {
- $error = 'Is not a number!';
- }
- else
- {
- $m = $_POST['cm'] / 100;
- }
- }
- ?>
- <!doctype html>
- <html>
- <head>
- <title>Centimeters to meters converter</title>
- <style type="text/css">
- .error {
- color: #f00;
- }
- </style>
- </head>
- <body>
- <form method="POST">
- <label for="cm">Centimeters</label>
- <input type="text" id="cm" name="cm" value="<?php if(isset($m)){echo $_POST['cm'];} ?>" size="5" />
- <button type="submit">Convert</button>
- </form>
- <?php
- if(isset($error))
- {
- echo " <span class=\"error\">{$error}</span>\n";
- }
- elseif(isset($m))
- {
- echo " There are <strong>{$m}</strong> meters to <strong>{$_POST['cm']}</strong> centimeters\n";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement