Smartphone price calculator in php

Hello viewer’s , You can calculate smartphone price by using this php program . This is a simple Smartphone price calculator . In this program we are calculating price on the base of three feature RAM , ROM , PROCESSOR .

If you want to learn how to create these type of PHP programs continue on this article . it will be very helpful for you .

Steps : How i created this Smartphone price calculator using PHP

Create a HTML form for collect information from user . 

In this HTML form i have created three radio input type for collect user requirements .First is RAM , Second is ROM and third is PROCESSOR .  Look this form step by step .

Read also : How to compare two words documents

Input type for ROM

calculator in php

Second input type for ROM

php rom calculator

Third  input type for PROCESSOR

php processor calculator

This is Complete HTML form for this Smartphone price calculator .

</head>
<body>
<center>
<br>
<h3>Select your requirements</h3>

<form action=”” method=”post”>
<hr><b>RAM : </b>
1 GB <input type=”radio” name=”ram” value=”1 GB”>
2 GB <input type=”radio” name=”ram” value=”2 GB”>
3 GB <input type=”radio” name=”ram” value=”3 GB”>
4 GB <input type=”radio” name=”ram” value=”4 GB”>
<br>
<br>

<b>ROM : </b>
8 GB<input type=”radio” name=”storage” value=”8 GB”>
16 GB<input type=”radio” name=”storage” value=”16 GB”>
32 GB<input type=”radio” name=”storage” value=”32 GB”>
64 GB<input type=”radio” name=”storage”value=”64 GB”>
128 GB<input type=”radio” name=”storage” value=”128 GB”>
<br>
<br>
<b>Processor : </b>
Snapdragon 425<input type=”radio” name=”processor” value=”425″>
Snapdragon 430<input type=”radio” name=”processor” value=”430″>
Snapdragon 625<input type=”radio” name=”processor” value=”625″>
Snapdragon 630<input type=”radio” name=”processor” value=”630″>
Snapdragon 825<input type=”radio” name=”processor” value=”825″>
<br>
<br>
<input type=”submit” name=”submit” value=”CALCULATE”>
</form>
</center>
</body>
</html>

Now we will look the server side process for this Smartphone price calculator in PHP .

php
if(isset($_POST[‘submit’]))
{
$ram = $_POST[‘ram’];
$rom = $_POST[‘storage’];
$processor = $_POST[‘processor’];

$ram_price = null;
if($ram==”1 GB”)
{
$ram_price = 1200;
}
else if ($ram == “2 GB”)
{
$ram_price = 2200;
}
else if($ram==”3 GB”)
{
$ram_price = 3100;
}
else if($ram==”4 GB”)
{
$ram_price = 4200;
}
//echo $ram_price;

$ram_price = null;
if($rom==”8 GB”)
{
$rom_price = 900;
}
else if($rom ==”16 GB”)
{
$rom_price = 1500;
}
else if($rom==”32 GB”)
{
$rom_price = 2100;
}
else if($rom == “64 GB”)
{
$rom_price = 3100;
}
else if($rom==”128 GB”)
{
$rom_price = 4200;
}

$p_price = null;
if($processor==”425″)
{
$p_price = 6500;
}
else if($processor==”430″)
{
$p_price = 8100;
}
else if ($processor==”625″)
{
$p_price = 9500;
}
else if($processor == “630”)
{
$p_price = 11500;
}
else if($processor ==”825″)
{
$p_price = 12000;
}

$total_price = $ram_price + $rom_price + $p_price ;
echo “<center><h4>Your Device Price is $total_price</h4></center>”;
}

?>

Final result of PHP Smartphone Price calculator .

php project smartphone price calculator

 

If you find this example helpful , please share it with your friends and follow us on Facebook .