# Posted By

JonnySnip3r on 04/08/11

# Statistics

Viewed 316 times
Favorited by 0 user(s)

# Simple calculate script

/ Published in: PHP
Save to your folder(s)

Simple as pie and chips...

Copy this code and paste it in your HTML
`<?php if(isset(\$_POST['sum1']) && isset(\$_POST['sum2']) && isset(\$_POST['calculate'])){	\$sum1 = strip_tags(\$_POST['sum1']);	\$sum2 = strip_tags(\$_POST['sum2']);	\$task = \$_POST['calculate']; 	if(!is_numeric(\$sum1) || !is_numeric(\$sum2))	{		echo 'Fuck you, you dirty little cunt!';	}	else	{		switch(\$task)		{			case 'add':				echo \$sum1 . ' + ' . \$sum2 . ' = ' . \$sum1 + \$sum2;				break;			case 'multiply':				echo \$sum1 . ' x ' . \$sum2 . ' = ' . \$sum1 * \$sum2;				break;			case 'subtract':				echo \$sum1 . ' - ' . \$sum2 . ' = ' . \$sum1 - \$sum2;				break;			default:				echo 'Get fucked!';				break;		}	}} ?> <form method="post" action="#"> 	<p>		<label>First Number: </label>		<input type="text" name="sum1" value="" />	</p> 	<p>		<select name='calculate'>			<option value='null'>Choose...</option>			<option value='add'>+</option>			<option value='multiply'>x</option>			<option value='subtract'>-</option>		</select>	</p> 	<p>		<label>Second Number: </label>		<input type="text" name="sum2" value="" />	</p> 	<p>		<input type="submit" name="submit" value="Calculate" />	</p></form>`