Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Sum two numbers in PHP with HTML input form

<!DOCTYPE html>
<html>
<head>
    <title>Sum</title>
</head>
<style>
    body {
        background: linear-gradient(110deg, #fdcd3b 60%, #ffed4b 60%); 
    }
    .container {
        width: 400px;
        margin: 0 auto;
        background-color: #eee;
        padding: 20px;
        border-radius: 10px;
        box-shadow: 0px 0px 10px #000;
    }
    .container1{
        width: 100px;
        margin: 0 auto;
        background-color: #eee;
        padding: 20px;
        border-radius: 10px;
        box-shadow: 0px 0px 10px #000;
        text-align: center; 
    }
    .container input {
        width: 80%;
        padding: 10px;
        margin-bottom: 10px;
    }
    .container button {
        width: 80%;
        padding: 10px;
        margin-bottom: 10px;
    }
    .container .result {
        width: 100%;
        padding: 10px;
        margin-bottom: 10px;
    }
     form{
            width: 300px;
            margin: 0 auto;
            text-align: center;
     }
        input{
                width: 200px;
                height: 30px;
                margin: 10px;
                border: 1px solid #ccc;
                border-radius: 5px;
                padding: 5px;
        }
        .container{
            width: 300px;
            margin: 0 auto;
            text-align: center;
            background-color: #ccc;
        }
        button{
            margin: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding: 5px;
            background-color: #34568B;
            width: 200px;
            color: #fff;
            font-weight: bold;
            font-size: 20px;
            padding: 10px;
            width: 200px;
        }
        button:hover{
            margin: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            background-color: #FF6F61;
            width: 200px;
            color: #fff;
            font-weight: bold;
            font-size: 20px;
            padding: 5px;
            width: 200px;
        }
 </style>
<body>
<div class="container">
<form>
    <input type="number" name="num1" placeholder="Number 1" />
    <input type="number" name="num2" placeholder="Number 2" />
    <button input type="submit" value="CHECK THE SUM">submit</button>
</form>
</div>

<?php
if (isset($_GET['num1']) && isset($_GET['num2'])) {
 
    $num1 = $_GET['num1'];
    $num2 = $_GET['num2'];
    $sum = $num1 + $num2;
    echo "<div class='container1'>";
    echo "<div class='result'>";
    echo  $num1 . " + " . $num2 . " = " . $sum;
}
?>
 
</body>
</html
Comment

sum two numbers in php

<?php  
$x=10;  
$y=20;  
$z = $x + $y;  
echo "Sum of x and y : ". $z;  
?>
Comment

How to sum 2 numbers in php.

<?php
  $i = 1;
  $j = 2;
 $a = $i + $j;
echo "The sum of i and j will be" . $a;
?>
Comment

PREVIOUS NEXT
Code Example
Php :: php find if string contains words from list index 
Php :: laravel mysql specified key was too long 
Php :: laravel capsule schema datatime CURRENT_TIMESTAMP 
Php :: h:i:s explode in php by ":" 
Php :: PHP MySQL Use The WHERE Clause 
Php :: random integer in php 
Php :: create array php 
Php :: toggle between login and logout buttons php 
Php :: how to get meta information from pagination in laravel controller 
Php :: php get 
Php :: how to make a loop that adds numbers to a variable in php 
Php :: sql update row in php 
Php :: create symfony 4 project 
Php :: give @s potion off weekness 
Php :: Laravel Adding Cookie Consent 
Php :: Verzeichnis einlesen php 
Php :: laravel 8 add column to existing table 
Php :: dispatch job with queue name in laravel 
Php :: php webpage to string 
Php :: laravel on cascade set null 
Php :: Multiple image upload with CodeIgniter 
Php :: artisan laravel require bootstrap 
Php :: how to create singleton laravel 
Php :: how to get client ip address in php 
Php :: Woocommerce get image galleries by product id 
Php :: Create Mysqli Table Using Php 
Php :: microft access request database with pdo 
Php :: php array serialize 
Php :: strpos php 
Php :: laravel multiple copy record 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =