Basic Salary Method In PHP For Beginners
<html>
<head>
<title>PHP Salary Calculator</title>
</head>
<body>
<form action="" method="post" >
<table>
<tr>
<td>
Full Name:</td><td><input type="text" name="fname"
/></td></tr>
<tr>
<td>
Basic Salary:</td><td><input type="text" name="salary"
required="required"/></td></tr>
</table>
<input type="submit" value="Calculate" /> <input type="reset" />
</form>
<?php
$fname = $_POST['fname'];
$salary = $_POST['salary'];
$show_CA = '';
$show_MA = '';
$show_HR = '';
$CA_Calculate ='' ;
$MA_Calculate = '';
$HR_Calculate = '';
$itax = '';
if($salary > 30000)
{
if($salary > 50000)
{
$itax =$salary * 3 / 100;
}
$show_CA = 20;
$show_MA = 30;
$show_HR = 40;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary > 25000)
{
$show_CA = 15;
$show_MA = 20;
$show_HR = 30;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary > 20000)
{
$show_CA = 10;
$show_MA = 15;
$show_HR = 25;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary < 20000)
{
$show_CA = 'fixed';
$show_MA = 'fixed';
$show_HR = 'fixed';
$CA_Calculate = 1000;
$MA_Calculate = 1500 ;
$HR_Calculate =2000 ;
}
$cal_salary = $salary + $CA_Calculate + $MA_Calculate + $HR_Calculate;
$pfund = $salary * 10 /100;
$netsalary = $cal_salary - ($pfund + $itax);
echo '<table style="font-family:tahoma;" width="25%"><tr><td >Full Name</td><td colspan="2" align="center" style="font-weight:bold;" >' .$fname . '</td></tr>';
echo '<tr><td>Basic Salary</td><td colspan="2" align="center" style="color:red;">' .$salary . '</td></tr>';
echo '<tr><td>CA</td><td>' .$show_CA . '%</td><td>'.$CA_Calculate.'</td></tr>';
echo '<tr><td>MA</td><td>' .$show_MA . '%</td><td>'.$MA_Calculate.'</td></tr>';
echo '<tr><td>HR</td><td>' .$show_HR . '%</td><td>'.$HR_Calculate.'</td></tr>';
echo '<tr><td>PFUND</td><td>10%</td><td>'.$pfund.'</td></tr>';
echo '<tr><td>ITax</td><td>3%</td><td>'.$itax.'</td></tr>';
echo '<tr><td>Net Salary</td><td style="color:green; font-size:30px;" colspan="2" align="center">'.$netsalary.'</td></tr>';
echo '<table>';
?>
</body>
</html>
<head>
<title>PHP Salary Calculator</title>
</head>
<body>
<form action="" method="post" >
<table>
<tr>
<td>
Full Name:</td><td><input type="text" name="fname"
/></td></tr>
<tr>
<td>
Basic Salary:</td><td><input type="text" name="salary"
required="required"/></td></tr>
</table>
<input type="submit" value="Calculate" /> <input type="reset" />
</form>
<?php
$fname = $_POST['fname'];
$salary = $_POST['salary'];
$show_CA = '';
$show_MA = '';
$show_HR = '';
$CA_Calculate ='' ;
$MA_Calculate = '';
$HR_Calculate = '';
$itax = '';
if($salary > 30000)
{
if($salary > 50000)
{
$itax =$salary * 3 / 100;
}
$show_CA = 20;
$show_MA = 30;
$show_HR = 40;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary > 25000)
{
$show_CA = 15;
$show_MA = 20;
$show_HR = 30;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary > 20000)
{
$show_CA = 10;
$show_MA = 15;
$show_HR = 25;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary < 20000)
{
$show_CA = 'fixed';
$show_MA = 'fixed';
$show_HR = 'fixed';
$CA_Calculate = 1000;
$MA_Calculate = 1500 ;
$HR_Calculate =2000 ;
}
$cal_salary = $salary + $CA_Calculate + $MA_Calculate + $HR_Calculate;
$pfund = $salary * 10 /100;
$netsalary = $cal_salary - ($pfund + $itax);
echo '<table style="font-family:tahoma;" width="25%"><tr><td >Full Name</td><td colspan="2" align="center" style="font-weight:bold;" >' .$fname . '</td></tr>';
echo '<tr><td>Basic Salary</td><td colspan="2" align="center" style="color:red;">' .$salary . '</td></tr>';
echo '<tr><td>CA</td><td>' .$show_CA . '%</td><td>'.$CA_Calculate.'</td></tr>';
echo '<tr><td>MA</td><td>' .$show_MA . '%</td><td>'.$MA_Calculate.'</td></tr>';
echo '<tr><td>HR</td><td>' .$show_HR . '%</td><td>'.$HR_Calculate.'</td></tr>';
echo '<tr><td>PFUND</td><td>10%</td><td>'.$pfund.'</td></tr>';
echo '<tr><td>ITax</td><td>3%</td><td>'.$itax.'</td></tr>';
echo '<tr><td>Net Salary</td><td style="color:green; font-size:30px;" colspan="2" align="center">'.$netsalary.'</td></tr>';
echo '<table>';
?>
</body>
</html>
No comments:
Post a Comment