maddog39
Feb 6 2005, 03:13 AM
Hello all, I was eally bored the other day. So I decided to make a php calculator just out of the blue. I set it up and it works really good. You can see mine here. Ill give you guys the source code too if you want it. Here it is... Name this calculate_forum.htmlCODE <html> <head> <title>Calculation Form</title> </head> <body> <form method="post" action="calculate.php"> <p>Value 1: <input type="text" name="val1" size="10"></p> <p>Value 2: <input type="text" name="val2" size="10"></p> <p>Calculation:<br> <input type="radio" name="calc" value="add"> add<br> <input type="radio" name="calc" value="subtract"> subtract<br> <input type="radio" name="calc" value="multiply"> multiply<br> <input type="radio" name="calc" value="divide"> divide</p> <p><input type="submit" name="submit" value="Calculate"></p> </body> </html>
Name this calculate.phpCODE <?php if (($_POST[val1] == "") || ($_POST[val2] == "") || ($_POST[calc] =="")) { header("Location: calculate_form.html"); exit; } if ($_POST[calc] == "add") { $result = $_POST[val1] + $_POST[val2]; } else if ($_POST[calc] == "subtract") { $result = $_POST[val1] - $_POST[val2]; } else if ($_POST[calc] == "multiply") { $result = $_POST[val1] * $_POST[val2]; } else if ($_POST[calc] == "divide") { $result = $_POST[val1] / $_POST[val2]; } echo "<title>Calculation Result</title>"; echo "<p>The result of the calculation is: $result</p>"; echo "<p><a href=\"calculate_form.html\" target=\"_self\">Do Another</a></p>"; ?>
Then upload the files to your server and go to www.yourdomain.com/calculate_form.html and enter 1 number in variable 1 and another number in variable 2. Then select a mathmatical method, then press calculate and then your answer will pop-up in a new page. The just click 'Do Another' to do another problem. Comments are appreciated. 
Reply
Cammy
Feb 6 2005, 04:26 AM
QUOTE(maddog39 @ Feb 6 2005, 03:13 AM) Hello all, I was eally bored the other day. So I decided to make a php calculator just out of the blue. I set it up and it works really good. You can see mine here. Ill give you guys the source code too if you want it. Here it is... Name this calculate_forum.htmlCODE <html> <head> <title>Calculation Form</title> </head> <body> <form method="post" action="calculate.php"> <p>Value 1: <input type="text" name="val1" size="10"></p> <p>Value 2: <input type="text" name="val2" size="10"></p> <p>Calculation:<br> <input type="radio" name="calc" value="add"> add<br> <input type="radio" name="calc" value="subtract"> subtract<br> <input type="radio" name="calc" value="multiply"> multiply<br> <input type="radio" name="calc" value="divide"> divide</p> <p><input type="submit" name="submit" value="Calculate"></p> </body> </html>
Name this calculate.phpCODE <?php if (($_POST[val1] == "") || ($_POST[val2] == "") || ($_POST[calc] =="")) { header("Location: calculate_form.html"); exit; } if ($_POST[calc] == "add") { $result = $_POST[val1] + $_POST[val2]; } else if ($_POST[calc] == "subtract") { $result = $_POST[val1] - $_POST[val2]; } else if ($_POST[calc] == "multiply") { $result = $_POST[val1] * $_POST[val2]; } else if ($_POST[calc] == "divide") { $result = $_POST[val1] / $_POST[val2]; } echo "<title>Calculation Result</title>"; echo "<p>The result of the calculation is: $result</p>"; echo "<p><a href=\"calculate_form.html\" target=\"_self\">Do Another</a></p>"; ?>
Then upload the files to your server and go to www.yourdomain.com/calculate_form.html and enter 1 number in variable 1 and another number in variable 2. Then select a mathmatical method, then press calculate and then your answer will pop-up in a new page. The just click 'Do Another' to do another problem. Comments are appreciated.  I just tried it , it was fun. If I use it Ill make sure I provide a link back to your site. BTW nice layout!
Reply
AnimeExile
Feb 6 2005, 04:54 AM
Wait till u see my layout =P. Nice php calculator.... but there are others where u dont have seperates boxes for each value, i assuma u know php and u know how to use {echo} etc.
Reply
maddog39
Feb 6 2005, 02:12 PM
Lol, thanks guys.
Reply
krap
Feb 7 2005, 04:35 PM
cool but a bit pointless
Reply
nancmu
Feb 8 2005, 10:05 AM
Good work, guy. That's a good once.
Reply
Deaths Aprentice
Feb 8 2005, 11:07 AM
Heh, nice one  . It's a very simple, yet usefull program
Reply
LuciferStar
Feb 8 2005, 12:37 PM
It's good. but in my opinion, using php to make a calculator,is not quite efficient. PHP has to post/GET the data,then display the result, but JAVASCRIPT can display the result without POST/GET action. JAVASCRIPT is faster in doing these.
Reply
maddog39
Feb 8 2005, 05:15 PM
Well I know it was a pointless project. But I did it out of bordum. I also dont have any knowledge of Javascript and right now im learning php. But I know that Javascript is better for this stuff. But it still works and I use it all the time.
Reply
Xedos
Feb 8 2005, 05:43 PM
Nice, simple, useful program. LuciferStar: Why do you think javascript is better? PHP is much more powerful and much more easy to learn.
Reply
iGuest
Sep 1 2008, 10:30 AM
Calculator in javascript
Php Calculator
I just checkout the calculator posted here by someonein in javascript .. But the problem is that it is showng the opreator in the text field also. So can any one send the code of calculator which dnt shw the operator in the text field and havn only the single text field -question by tarundeep singh
Reply
maddog39
Feb 24 2005, 02:36 AM
Well guys since you asked anyway. I have made and posted a Javascript version thats I also believe is alot better. Its got tons more capabilities and stuff. I posted the code to. So just go to: http://www.trap17.com/forums/Js-Calculator-t7499.html
Reply
LuciferStar
Feb 11 2005, 08:34 AM
Well,everybody, we may conside that many things can be solved by many different ways. What we may do is try to find the best neat path. BTW, PHP,JSP,ASP are server-side scripts, Javascript,vbscript are client-side scripts.
Reply
FaLgoR
Feb 11 2005, 12:59 AM
QUOTE(Xedos @ Feb 8 2005, 02:43 PM) Nice, simple, useful program. LuciferStar: Why do you think javascript is better? PHP is much more powerful and much more easy to learn. yes, php is much more simply, but javascript is faster. The javascript code are load in the HTML page, and when it's done, you click on the button 'Calculate' and the result come at the same time. PHP needs to load an other page, an go back to another calc, and load the page again....
Reply
maddog39
Feb 10 2005, 09:58 PM
Wow! you guys are really serious about your coding/scripts. Im scared, lol. I did this out of boardom. Thats why theres no copyright and other special stuff.
Reply
Recent Queries:--
php, make a calculator with classes - 7.63 hr back. (1)
-
how to code a calculator using php - 8.26 hr back. (2)
-
php calculator with code - 8.47 hr back. (2)
-
calculator php codes - 13.70 hr back. (1)
-
php code calculator - 14.11 hr back. (1)
-
simple kilometres calculator code in php - 14.57 hr back. (1)
-
use form to do php calculation - 15.75 hr back. (1)
-
very basic php calculator - 16.03 hr back. (1)
-
simple calculator php - 16.11 hr back. (1)
-
simple calculator made using php - 16.96 hr back. (1)
-
calculate page load in php - 18.25 hr back. (1)
-
php calculator tutorial - 14.43 hr back. (3)
-
jsp code for calculator - 22.21 hr back. (1)
-
how to make a calculation form in php - 31.05 hr back. (1)
Similar Topics
Keywords : php, calculator, simple, cool
- Php Calculator That Calculates Genetic Percentages?
I need help finding sites or tutorials. (2)
Looking for php, calculator, simple, cool
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for php, calculator, simple, cool
*MORE FROM TRAP17.COM*
|
advertisement
|
|