How Do I Implement PHP Code For Adding Two Numbers

admin_img Posted By Bajarangi soft , Posted On 27-11-2020

Using php we can add two numbers on submit of form .So today we discuss how to do it.

How Do I Implement PHP Code For Adding Two Numbers

Complete Code For Implementing PHP Code For Adding Two Numbers.

<!DOCTYPE html>
<html>
<head>
    <title>How Do I Implement PHP Code For Adding Two Numbers</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<style>
    body {
        background: black;
    }
</style>
<body>
<body>
<div class="container">
    <br/><br/>
    <div class="text-center">
        <h1 id="color" style="color: white;">Implement PHP Code For Adding Two Numbers</h1>
    </div>

    <div class="well">
        <form action="" method="post" enctype="multipart/form-data">
            <label>Number 1</label>
            <input type="text" name="number1" value=""><br><br>
            <label>Number 2</label>
            <input type="text" name="number2" value=""><br><br>
            <input type="submit" value="submit" class="btn btn-success" name="submit">
        </form>
        <?php
        if (isset($_POST['submit'])) {
            $n1=$_POST['number1'];
            $n2=$_POST['number2'];
            $output =$n1+$n2;
            echo "$n1 + $n2 =".$output ;
        }
        ?>
    </div>
</div>
</body>
</html>

Related Post