Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>Add two numbers</title>
- </head>
- <body>
- <?php
- if (isset($_POST['submitted'], $_POST['num1'], $_POST['num2'])) {
- $sum = (int)$_POST['num1'] + (int)$_POST['num2'];
- $out = sprintf('%d + %d = %d', $_POST['num1'], $_POST['num2'], $sum);
- echo <<<EOD
- <h1>two numbers added</h1>
- <p>$out</p>
- <a href="">add more numbers</a>
- EOD;
- } else {
- echo <<<EOD
- <h1>Add two numbers</h1>
- <form action="" method="post">
- <p>
- <input type="text" name="num1" /> +
- <input type="text" name="num2" />
- </p>
- <input type="submit" value="add" />
- <input type="hidden" name="submitted" value="true" />
- </form>
- EOD;
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment