Jump to content
Parabot - Bot for Ikov, DreamScape, SoulPlay, RuneWild, and more
Sign in to follow this  

[Short Tutorial] Simple calculator

Recommended Posts

A simple tutorial

<!-- This is the HTML part -->

<head><title>Simple PHP Calculator made by ParaDox</title></head>
<!-- For this calculator we will use post -->
<form method="post">
<!-- Here we make a form for our first number and we call it "firstnum" -->
First number:
 <input type="text" name="firstnum">
 <!-- Here we make a dropdown box for the sort of operator -->
Sort operator:
 <select name="operator">
 <!-- Here we make a form for our second number and we call it "secondnum" -->
Second Number:
 <input type="text" name="secondnum">
 <!-- Here we make our button to let the calculator do his job and we call the button "Calculate" -->
<input type="submit" name="calculate" value="Calculate">

 <!-- Now the PHP part -->

 <!-- Well this is easy to understand I think, LOL -->
 if ($operator=="+")
  {$total=$first + $second;}
 if ($operator=="-")
  {$total=$first - $second;}
 if ($operator=="*")
  {$total=$first * $second;}
 if ($operator=="/")
  {$total=$first / $second;}
 echo $total;

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...