Search
 
SCRIPT & CODE EXAMPLE
 

PHP

using php to add numbers in html 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

PREVIOUS NEXT
Code Example
Php :: laravel How to capture output in a file from php artisan test 
Php :: php artisan tinker encryption cmd 
Php :: laravel eloquent multiple join with where conditions 
Php :: how to sort with array and after print by for loop in php 
Php :: check the request type in laravel 
Php :: php regex replace to remove special characters and accented 
Php :: german locale php 
Php :: laravel local scope 
Php :: country code validation in laravel 
Php :: declare variable in php class 
Php :: isempty php 
Php :: how to delete item from array php 
Php :: laravel parse markdown 
Php :: laravel valet refresh env 
Php :: last item coma replace and php 
Php :: status messages wordpress settings form 
Php :: php date list 
Php :: url segment laravel 
Php :: laravel phpdoc collection of model 
Php :: laravel create session table 
Php :: symfony messenger routing 
Php :: wordpress debug mode 
Php :: php declare array 
Php :: how to upload large video file in php 
Php :: laravel select where with total sum query to get all data with sum 
Php :: vs code php tag shortcut 
Php :: yii2 gridview action change urls 
Php :: mp3 file upload code in php 
Php :: laravel 8 seeding 
Php :: laravel sharing data 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =