 # Income tax form

I’m making a script calculating income tax.

The income is supposed to be entered through a form and then calculated like below:

[ul][li]If income is less than (or equal to) 8900 kr, 0 kr tax is paid.[/li]
[li]If income is greater than 8900 kr but less than 198700 kr, 100 kr tax is paid.[/li]
[li]If income is greater than (or equal to) 198700 k, 100 kr + 20 % tax is paid on the income over 198700 kr.[/li][/ul]

I don’t know how to incorporate my php to the form in one page.

[php]<?php

function taxCalc(\$income) {

if (\$income > 0 && \$income <= 8900) return ‘0kr’;
else if (\$income > 8900 && \$income < 198700) return ‘100kr’;
else return (100+(\$income . 198700) * 0.2) . ‘kr’;
}

echo “Du betalar " . taxCalc((float)\$_GET[‘income’]) . " i skatt”;
?> [/php]

Help would be apprechiated.

[php]<?php

function taxCalc(\$income) {
if (\$income > 0 && \$income <= 8900) {
return ‘0’;
} elseif (\$income > 8900 && \$income < 198700) {
return ‘100’;
} else {
return (\$income * 0.2) + 100;
}
}

\$income = !empty(\$_GET[‘income’]) ? \$_GET[‘income’] : 0;

echo "Du betalar " . taxCalc((float)\$income) . “kr i skatt”;[/php]

Thank you,
and how do I do to add a form where you enter your income and calculate the tax through the php?

Just add a form beneath it.

[php]<?php
function taxCalc(\$income) {
if (\$income > 0 && \$income <= 8900) {
return ‘0’;
} elseif (\$income > 8900 && \$income < 198700) {
return ‘100’;
} else {
return (\$income * 0.2) + 100;
}
}

\$income = !empty(\$_GET[‘income’]) ? \$_GET[‘income’] : 0;

if (!empty(\$income)) { ?>

#### Du betalar <?= taxCalc((float)\$income) ?>kr i skatt

<?php } ?> Submit [/php]