Quote:
De verbeterde v1.3 is online
Met de verbeteringen:
* Decimale getallen bij uitslag
* Maximaal 100% invullen
* Errors
- Error is uitgelegdt wanneer er een error is.
- Error van "Alleen getallen invullen" is verbeterd van ctype_digit naar is_numeric
* Nederlandse BTW zit er ook in
Hallo,
Ik volg al even een PHP TUT, ik verveelde me nu net even, en heb een klein BTW scriptje gemaakt.
Voor diegene die niet snapt hoe de script het BTW berekent:
Je leerde op school toch dat je btw berekend door het bedrag te delen door 100 en dan maal het aantal procent te doen? Zo werkt dit script ook, maar dan met $_POST etc.
Ik ben zo blij dat ik dit heb kunnen maken, dit is een van mijn eerste PHP snippets dat ik heb zelf kunnen maken!
Je mag het gratis gebruiken.
Ook zou ik graag van mensen die er verstand van hebben Tips/verbeteringen krijgen.
Reacties mogen ook altijd
Sander
De verbeterde v1.3 is online
Met de verbeteringen:
* Decimale getallen bij uitslag
* Maximaal 100% invullen
* Errors
- Error is uitgelegdt wanneer er een error is.
- Error van "Alleen getallen invullen" is verbeterd van ctype_digit naar is_numeric
* Nederlandse BTW zit er ook in
Hallo,
Ik volg al even een PHP TUT, ik verveelde me nu net even, en heb een klein BTW scriptje gemaakt.
Voor diegene die niet snapt hoe de script het BTW berekent:
Je leerde op school toch dat je btw berekend door het bedrag te delen door 100 en dan maal het aantal procent te doen? Zo werkt dit script ook, maar dan met $_POST etc.
Ik ben zo blij dat ik dit heb kunnen maken, dit is een van mijn eerste PHP snippets dat ik heb zelf kunnen maken!
Je mag het gratis gebruiken.
(Versie_1.2)
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*
*Copyright = Sander Corens
*Functie = Het berekenen van de BTW bij een bedrag en zeggen hoeveel de BTW is
*Versie = v1.2 | Gratis versie, niet doorverkopen of claimen als uw eigen
*/[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]])){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt iets fout gedaan[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]btw[/COLOR][COLOR= #007700]])){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je hebt iets fout gedaan[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/ctype_digit"]ctype_digit[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je hebt iets fout gedaan[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/ctype_digit"]ctype_digit[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]btw[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je hebt iets fout gedaan[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]][/COLOR] / [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]btw[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$totaalbtw[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]De btw bedraagd = [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$totaal[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] Euro<br/>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Het bedrag met de BTW erbij = [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$totaalbtw[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] Euro[/COLOR][COLOR= #007700];
}
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
<form action ="#" method="POST">
<input type="text" name="bedrag" placeholder="Bedrag"><br/>
<input type="text" name="btw" placeholder="BTW"> %<br/>
<input type="submit" value="Bereken BTW" />
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?>[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*
*Copyright = Sander Corens
*Functie = Het berekenen van de BTW bij een bedrag en zeggen hoeveel de BTW is
*Versie = v1.3 | Gratis versie, niet doorverkopen of claimen als uw eigen
*/[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]])){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt het vakje voor het bedrag leeg gelaten![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]btw[/COLOR][COLOR= #007700]])){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je hebt het vakje voor de BTW leeg gelaten![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/is_numeric"]is_numeric[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Alleen gehele getallen invullen![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/is_numeric"]is_numeric[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]btw[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Alleen gehele getallen invullen![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]btw[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je kan niet meer dan 100% BTW hebben![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]][/COLOR] / [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]btw[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$totaalbtw[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]De btw bedraagd = [/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/number_format"]number_format[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totaal[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000] [/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000] Euro<br/>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Het bedrag met de BTW erbij = [/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/number_format"]number_format[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totaalbtw[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000] [/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000] Euro[/COLOR][COLOR= #007700];
}
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
<form action ="#" method="POST">
<input type="text" name="bedrag" placeholder="Bedrag"> //Je kan alleen nog maar gehele getallen invullen, kommagetallen gaat niet! Dit komt er in de volgende versie bij!<br/>
<input type="text" name="btw" placeholder="BTW"> %<br/>
<input type="submit" value="Bereken BTW" />
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?>
======================================
Alleen Nederland 19% BTW hier onder
======================================
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*
*Copyright = Sander Corens
*Functie = Het berekenen van de BTW bij een bedrag en zeggen hoeveel de BTW is
*Versie = v1.3 | Gratis versie, niet doorverkopen of claimen als uw eigen
*Nieuw in deze versie: Decimale getallen bij uitslag | Maximaal 100% invullen | Error is uitgelegdt wanneer er een error is. | Error van "Alleen getallen invullen" is verbeterd van ctype_digit naar is_numeric
*/[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]])){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt het vakje voor het bedrag leeg gelaten![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/is_numeric"]is_numeric[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Alleen getallen invullen![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]][/COLOR] / [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]19[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$totaalbtw[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]De btw bedraagd = [/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/number_format"]number_format[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totaal[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000] [/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000] Euro<br/>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Het bedrag met de BTW erbij = [/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/number_format"]number_format[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totaalbtw[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000] [/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000] Euro[/COLOR][COLOR= #007700];
}
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
<form action ="#" method="POST">
<input type="text" name="bedrag" placeholder="Bedrag"><br/>
<input type="submit" value="Bereken BTW" />
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?> Ook zou ik graag van mensen die er verstand van hebben Tips/verbeteringen krijgen.
Reacties mogen ook altijd

Sander

. Niet noodzakelijk maar toch
.
. En ik doe het niet met array omdat het minder dan 5 ifjes zijn dus dan vindt ik dat makelijker!

