Results 1 to 4 of 4
  1. #1
    MonsterCat
    Insan3Lik3
    CheeseToast's Avatar
    Join Date
    Apr 2011
    Location
    Calgary, Alberta, Canada
    Posts
    4,684
    Points
    4,169
         User Info     Contact     Gamer ID
    Join Date
    Apr 2011
    Location
    Calgary, Alberta, Canada
    Posts
    4,684
    Points
    4,169

    Contact info:

    Youtube Channel: http://www.youtube.com/CheeseToastHax

    Default PHP/HTML Calculator

    cheesetoast.me/usless_projects/calculator.php

    Code:
        <form method="post" action="calculator.php" class="form">
        <label>Number 1</label>
        <input type="text" name="number_1" x-webkit-speech value="<?php echo $_POST["number_1"]; ?>">
        <br/>
        <label>Number 2</label>
        <input type="text" name="number_2" x-webkit-speech value="<?php echo $_POST["number_2"]; ?>">
        <br/>
        <label>Operator</label>
        <input type="text" name="operator" x-webkit-speech value="<?php echo $_POST["operator"]; ?>">
        <br/>
        <input type="submit" value="Calculate!">
        </form>
    
    <?php
    $input_num1 = $_POST["number_1"];
    $input_num2 = $_POST["number_2"];
    $input_operator = $_POST["operator"];
    
    function calculate($num1, $num2, $op)
    {
        switch($op)
        {
            case "+":
                $answer = $num1 + $num2;
                return $answer;
            break;
            
            case "-":
                $answer = $num1 - $num2;
                return $answer;
            break;
            
            case "x":
                $answer = $num1 * $num2;
                return $answer;
            break;
            
            case "X":
                $answer = $num1 * $num2;
                return $answer;
            break;
            
            case "*":
                $answer = $num1 * $num2;
                return $answer;
            break;
            
            case "/":
                $answer = $num1 / $num2;
                return $answer;
            break;
            
            default:
                echo "Please enter in +, -, x, or /";
            break;
        }
    }
        echo calculate($input_num1,$input_num2,$input_operator);
        echo $answer;
    
    ?>
    Have any questions on how it works? Just ask.

    0 Not allowed! Not allowed!
    "It's better to lose an argument/debate then to win. Cause when you lose you grow as a person."
    -CheeseToast

  2. #2
    Robot Universe Owner
    Creator of DarkFrost
    demon450's Avatar
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,714
    Points
    6,203
         User Info     Contact     Gamer ID
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,714
    Points
    6,203
    Gamer IDs

    Gamertag: Medius450 PSN ID: Medius1337

    Contact info:

    Youtube Channel: http://www.youtube.com/user/Roceso1337

    Default

    why would you use php when you could just use javascript

    0 Not allowed! Not allowed!
    Check out Darkfrost
    Check out Robot Universe






  3. #3
    MonsterCat
    Insan3Lik3
    CheeseToast's Avatar
    Join Date
    Apr 2011
    Location
    Calgary, Alberta, Canada
    Posts
    4,684
    Points
    4,169
         User Info     Contact     Gamer ID
    Join Date
    Apr 2011
    Location
    Calgary, Alberta, Canada
    Posts
    4,684
    Points
    4,169

    Contact info:

    Youtube Channel: http://www.youtube.com/CheeseToastHax

    Default

    Not much of a difference, The only difference is it does a quick reload on every change.
    I haven't really started JavaScript yet, but I gotta start web programming somewhere.

    0 Not allowed! Not allowed!
    "It's better to lose an argument/debate then to win. Cause when you lose you grow as a person."
    -CheeseToast

  4. #4
    Elite Slowduck's Avatar
    Join Date
    Jun 2011
    Location
    All the places
    Posts
    10,204
    Points
    9,472
         User Info     Contact     Gamer ID
    Join Date
    Jun 2011
    Location
    All the places
    Posts
    10,204
    Points
    9,472

    Default

    I actually just used this to do my hw.

    0 Not allowed! Not allowed!


Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -10. The time now is 01:34 AM.
Powered by vBulletin®
Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.