Percentage Calculator to Create Using PHP HTML

Hello Friends Today, through this tutorial, I will tell you How to Write Program Percentage calculator using PHP with HTML? To create a Percentage Calculator using PHP with HTML, you can create a simple PHP script that takes input from a form, performs the calculation, and displays the result. Below is an example of how you can create a Percentage Calculator using PHP and HTML:

Create a file named `percentage_calculator.php` with the following content:

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Percentage Calculator</title>
body {
font-family: Arial, sans-serif;
margin: 20px;
label {
display: block;
margin-bottom: 8px;
input[type="number"] {
width: 100%;
padding: 8px;
margin-bottom: 16px;
box-sizing: border-box;
button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
button:hover {
background-color: #45a049;
<h2>Percentage Calculator</h2>
<form method="post">
<label for="number">Enter Number:</label>
<input type="number" id="number" name="number" placeholder="Enter a number" required><br>
<label for="percentage">Enter Percentage:</label>
<input type="number" id="percentage" name="percentage" placeholder="Enter a percentage" required><br>
<button type="submit">Calculate</button>

// Check if form is submitted

// Retrieve form data
$number = $_POST["number"];
$percentage = $_POST["percentage"];

// Calculate percentage
$result = ($number * $percentage) / 100;

// Display result
echo "<h3>Result:</h3>";
echo "<p>{$percentage}% of {$number} is {$result}</p>";


This PHP script displays a simple HTML form where users can input a number and a percentage. When the form is submitted, the PHP script calculates the percentage and displays the result below the form.

You can run this PHP script on a server with PHP support. Place the file in your server’s document root directory and access it through a web browser. For example, if your server is running locally, you can access it at `http://localhost/percentage_calculator.php`.