Php Calculator - Simple but cool.

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #17) by iGuest on Sep 1 2008, 10:30 AM. (Line Breaks Removed)
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... read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Php Calculator - Simple but cool.

maddog39
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.html
CODE

<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.php
CODE

<?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. biggrin.gif

 

 

 


Reply

Cammy
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.html
CODE

<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.php
CODE

<?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. biggrin.gif
*




I just tried it , it was fun. biggrin.gif If I use it Ill make sure I provide a link back to your site. BTW nice layout! biggrin.gif

 

 

 


Reply

AnimeExile
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
Lol, thanks guys. biggrin.gif

Reply

krap
cool but a bit pointless wink.gif ph34r.gif

Reply

nancmu
Good work, guy. smile.gif
That's a good once. wink.gif

Reply

Deaths Aprentice
Heh, nice one smile.gif.
It's a very simple, yet usefull program smile.gif

Reply

LuciferStar
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
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. biggrin.gif

Reply

Xedos
Nice, simple, useful program.

LuciferStar: Why do you think javascript is better? PHP is much more powerful and much more easy to learn.

Reply

Latest Entries

iGuest
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
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
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
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
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. laugh.gif tongue.gif biggrin.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Recent Queries:-
  1. php, make a calculator with classes - 7.63 hr back. (1)
  2. how to code a calculator using php - 8.26 hr back. (2)
  3. php calculator with code - 8.47 hr back. (2)
  4. calculator php codes - 13.70 hr back. (1)
  5. php code calculator - 14.11 hr back. (1)
  6. simple kilometres calculator code in php - 14.57 hr back. (1)
  7. use form to do php calculation - 15.75 hr back. (1)
  8. very basic php calculator - 16.03 hr back. (1)
  9. simple calculator php - 16.11 hr back. (1)
  10. simple calculator made using php - 16.96 hr back. (1)
  11. calculate page load in php - 18.25 hr back. (1)
  12. php calculator tutorial - 14.43 hr back. (3)
  13. jsp code for calculator - 22.21 hr back. (1)
  14. how to make a calculation form in php - 31.05 hr back. (1)
Similar Topics

Keywords : php, calculator, simple, cool

  1. 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



Php Calculator - Simple but cool.



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE