[R1.1 , PHP , No advanced]Calculator R1.1

Status
Not open for further replies.
Nov 23, 2010
307
2
Hello devbests :)
Well , my R1 of calculator had enough bugs, as i fixed it , i was thinking to release it here
Notice : R2 is not released yet , that is all the same as R1 BUT.. fixed bugs , added <center> and background colour (sucks :p)
2. If you wanna flame , do not comment.

Screenie :
You must be registered for see images attach


PHP code :
PHP:
<html>
<head>
<title>Calculator</title>
</head>
<body> 
<style type="text/css">
body
{
background-color: #00CCFF;
}
</style>
<center>
<b><i><font color="red">Hey peoples, you're in calculator coded by StronGCoder , Have fun!!!<br>
Today is <?php echo date("d/m/"); // shows day and month
if(date("y") == "10") 
{
echo "2010"; // if year is "10 (2010)" shows 2010 (not 10)
}
else
{
echo "/2011"; // if year is not 10 (2010) shows 2011 (not 11)
}
?>
<br>Tommorow is <?php //Start of PHP
echo date("d")+1; // shows day (+1)
echo date("/m"); // shows month
if(date("y") == "10")
{
echo "/2010"; // if year is "10 (2010)" shows /2010 (not /10)
}
else
{
echo "/2011"; // if year is not 10 (2010) shows /2011 (not /11)
}
// Ends PHP ?>
</b></i></font>
<br><br>
<?php //Start of PHP
//First , we make form.
echo "<form action='./index.php' method='post'>"; // form start
echo "<input type='number' name='x' value='0'>"; // First number , known as X!
echo "<select name='operator'>"; // the operator select
echo "<option>Choose the operator</option>"; // Choosing the operator , Fills the error if not set.
echo "<option>+</option>"; // if operator is +
echo "<option>-</option>"; // if operator is -
echo "<option>*</option>"; // if operator is *
echo "<option>/</option>"; // if operator is /
echo "</select>"; // select end
echo "<input type='number' name='y' value='0'>"; // second number , known as Y!
echo "<br><input type='submit' value='Calculate'>"; // Submit button saying "CALCULATE"
//  here ends the form
// if , else , if functions !
// if things are not set up
if(!$_POST["x"]) // if X is not set up 
{
echo "<b><font color='purple'>"; // font color is Black and Bold
echo "<br>Fill the first number please"; // shows the error
}
if(!$_POST["operator"]) // if operator is not set up 
{
echo "<br>Fill the operator"; // shows the error
}
if(!$_POST["y"]) // if Y is not set up 
{ 
echo "<br>Fill the second number please"; // Shows the error
}
// if things are not set up ends.
//if things are left as they are
if($_POST["x"] == "0") // if X is left as it is 
{
echo "<br>Fill the first number please"; // shows the error
}
if($_POST["operator"] == "Choose the operator") // if operator is left as it is
{
echo "<br>Choose the operator please"; // shows the error
}
if($_POST["y"] == "0") // if Y is left as it is
{
echo "<br>Fill the second number please"; // shows the error
}
//if things are left as they are ends.
// if things are set up correct
if($_POST["operator"] == "+") // if operator is filled as + 
{
echo "<br>"; // new line
echo  $_POST["x"] . " + " . $_POST["y"]; // shows the fill
echo " = "; // shows " = "
echo $_POST["x"] + $_POST["y"]; // shows correct value
}
if($_POST["operator"] == "-") // if operator is filled as -
{
echo "<br>"; // new line
echo $_POST["x"] . " - " . $_POST["y"]; // shows the fill
echo " = "; // shows " = "
echo $_POST["x"] - $_POST["y"]; // shows correct value
}
if($_POST["operator"] == "*") // if operator is filled as *
{
echo "<br>"; // new line
echo $_POST["x"] . " * " . $_POST["y"]; // shows the fill
echo " = "; // shows " = "
echo  $_POST["x"] * $_POST["y"]; // shows correct value
}
if($_POST["operator"] == "/") // if operator is filles as /
{
echo "<br>";  // new line
echo $_POST["x"] . " / " . $_POST["y"]; // shows the fill
echo " = "; // shows " = "
echo $_POST["x"] / $_POST["y"]; // shows correct value
}
// if things are set up correct ends .
// end with if , else , if functions
//ends PHP ?>
</center></b></font>
</form>
</body>
</html>

Everything is tested , and found NO BUGS!
If you have found any bug , report !

-------------------------------------------
R2 features (coming soon)
* Advanced with "(" ")"
* Custimozed with CSS
* With Non of bugs.
* 100% working
* 70% PHP , 20% HTML , 10% CSS
* Those things that advanced calculator should have :p

Thanks!
Rate ?/10
Hope you like it ,
StronGCoder!
 

Схаваць

New Member
Nov 29, 2010
7
0
i found some erros
Code:
''echo
Fill the first number please"; // shows the error } if(!$_POST["operator"]) // if operator is not set up { echo "
Fill the operator"; // shows the error } if(!$_POST["y"]) // if Y is not set up { echo "
Fill the second number please"; // Shows the error } // if things are not set up ends. //if things are left as they are if($_POST["x"] == "0") // if X is left as it is { echo "
Fill the first number please"; // shows the error } if($_POST["operator"] == "Choose the operator") // if operator is left as it is { echo "
Choose the operator please"; // shows the error } if($_POST["y"] == "0") // if Y is left as it is { echo "
Fill the second number please"; // shows the error } //if things are left as they are ends. // if things are set up correct if($_POST["operator"] == "+") // if operator is filled as + { echo "
"; // new line echo $_POST["x"] . " + " . $_POST["y"]; // shows the fill echo " = "; // shows " = " echo $_POST["x"] + $_POST["y"]; // shows correct value } if($_POST["operator"] == "-") // if operator is filled as - { echo "
"; // new line echo $_POST["x"] . " - " . $_POST["y"]; // shows the fill echo " = "; // shows " = " echo $_POST["x"] - $_POST["y"]; // shows correct value } if($_POST["operator"] == "*") // if operator is filled as * { echo "
"; // new line echo $_POST["x"] . " * " . $_POST["y"]; // shows the fill echo " = "; // shows " = " echo $_POST["x"] * $_POST["y"]; // shows correct value } if($_POST["operator"] == "/") // if operator is filles as / { echo "
"; // new line echo $_POST["x"] . " / " . $_POST["y"]; // shows the fill echo " = "; // shows " = " echo $_POST["x"] / $_POST["y"]; // shows correct value } // if things are set up correct ends . // end with if , else , if functions //ends PHP ?>
 
Nov 23, 2010
307
2
i found some erros
Code:
''echo
Fill the first number please"; // shows the error } if(!$_POST["operator"]) // if operator is not set up { echo "
Fill the operator"; // shows the error } if(!$_POST["y"]) // if Y is not set up { echo "
Fill the second number please"; // Shows the error } // if things are not set up ends. //if things are left as they are if($_POST["x"] == "0") // if X is left as it is { echo "
Fill the first number please"; // shows the error } if($_POST["operator"] == "Choose the operator") // if operator is left as it is { echo "
Choose the operator please"; // shows the error } if($_POST["y"] == "0") // if Y is left as it is { echo "
Fill the second number please"; // shows the error } //if things are left as they are ends. // if things are set up correct if($_POST["operator"] == "+") // if operator is filled as + { echo "
"; // new line echo $_POST["x"] . " + " . $_POST["y"]; // shows the fill echo " = "; // shows " = " echo $_POST["x"] + $_POST["y"]; // shows correct value } if($_POST["operator"] == "-") // if operator is filled as - { echo "
"; // new line echo $_POST["x"] . " - " . $_POST["y"]; // shows the fill echo " = "; // shows " = " echo $_POST["x"] - $_POST["y"]; // shows correct value } if($_POST["operator"] == "*") // if operator is filled as * { echo "
"; // new line echo $_POST["x"] . " * " . $_POST["y"]; // shows the fill echo " = "; // shows " = " echo $_POST["x"] * $_POST["y"]; // shows correct value } if($_POST["operator"] == "/") // if operator is filles as / { echo "
"; // new line echo $_POST["x"] . " / " . $_POST["y"]; // shows the fill echo " = "; // shows " = " echo $_POST["x"] / $_POST["y"]; // shows correct value } // if things are set up correct ends . // end with if , else , if functions //ends PHP ?>

WTF??! where's the error here ?
 

RastaLulz

fight teh power
Staff member
May 3, 2010
3,926
3,921
It's not bad for a beginner, but it code be a lot better. Also, try to make your code more clean - it's very messy at the moment.
 
Status
Not open for further replies.

Users who are viewing this thread

Top