Get up to 80 % extra points for free! More info:

Discussion: Lesson 5 - Associative arrays in PHP and submitting forms

Back

 

Comments
Avatar
belay ozil
Member
Avatar
belay ozil:6/12/2017 10:01

the calculator zip code is not working for me what's the problem?????????

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Calcula­tor</title>
</head>
<body>
<?php
<p>Welcome to the calculator, please enter 2 numbers and you will get their sum.</p>

<form method="POST" action="sum.php">
<input name="number1" type="text" /><br />
<input name="number2" type="text" /><br />
<input type="submit" value="compute" />

$sum = $_GET['number1'] + $_GET['number2'];
echo("Sum: $sum");

$sum = $_POST['number1'] + $_POST['number2'];
echo("Sum: $sum");

</form>
?>

</form>

</body>
</html>

Reply
6/12/2017 10:01
programming is my life
Avatar
Replies to belay ozil
David Capka Hartinger:6/12/2017 10:40

This is not the code from our zip archive. You're mixing PHP and HTML code. Download the zip archive and look into the files, it'll help you to understand your mistakes.

Reply
6/12/2017 10:40
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Replies to belay ozil
ramkumar saini:8/27/2020 7:52
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Calculator</title>
    </head>
    <body>
        <p>Welcome to the calculator, please enter 2 numbers and you will get their sum.</p>

        <form method="POST" action="sum.php">
            <input name="number1" type="text" /><br />
            <input name="number2" type="text" /><br />
            <input type="submit" value="Compute" />
        </form>

    </body>
</html>
<?php
$sum = $_POST['number1'] + $_POST['number2'];
echo("Sum Value: $sum");

?>
 
Reply
8/27/2020 7:52
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

3 messages from 3 displayed.