[PHP]Calculator

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Account Upgraded | Title Enabled! StrongFaith is offline
    MemberRank
    Aug 2010 Join Date
    .PHP filesLocation
    268Posts

    [PHP]Calculator

    Hello Ragezoners , i made a calculator , its VERY SIMPLE tho , dont flame me.
    so here it is !
    PHP Code:
    <h1>Simple calculator - Usable</h1>
    <h3>Source by foxx - thank you and edited by StronGCoder</h3>
    <h1>Simple calculator - Usable</h1>
    <h3>Source by foxx - thank you and edited by StronGCoder</h3>
    <?php
    // source by foxx - thanks!
    // edited by strong
    // advanced calculator coming soon!
    $result "";
    if (isset(
    $_POST['val'])) {
        
    $val = (float)$_POST['val'];
        
    $val2 = (float)$_POST['val2'];

        if (!
    $val and $val2) {
            
    $result .= "<p>Fill all fields , please!</p>";
        }

        
        if (!
    $result) {
            switch (
    $_POST['operator']) {
                case 
    "sum":
                    
    $result $val.'+'.$val2.' = '.$val+$val2;
                    break;
                case 
    "sub":
                    
    $result $val.'-'.$val2.' = '.$val-$val2;
                    break;    
                case 
    "mul":
                    
    $result $val.'*'.$val2.' = '.$val*$val2;
                    break;    
                case 
    "div":
                    
    $result $val.'/'.$val2.' = '.$val/$val2;
                    break;    
            }
        }
    }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cz" lang="cz"> 
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="Content-Language" content="en" />

        <title>Calculator by StronGCoder</title>
    </head>

    <body>
        <form method="post" action="/calculator/index.php"> 
                <label for="val"></label>
                <input type="text" name="val" id="val" value='First number' />
                
                <label for="operator"></label>
                
                    <select name="operator" id="operator">
                        <option value="Choose">Choose one :</option>                    
                        <option value="sum">+</option>
                        <option value="sub">-</option>
                        <option value="mul">*</option>
                        <option value="div">/</option>
                    </select>
                
                
                <label for="val2"></label>
                <input type="text" name="val2" id="val2" value='Second number' />
            
                <input type="submit" name="submit" value='Calculate' />

           
        </form>

        <?php
            
    echo $result;
        
    ?>
    </body>

    </html>


    credits
    50% - foxx - the base source
    50% - me - coding , fixing , editing !
    thanks!
    Last edited by StrongFaith; 24-11-10 at 10:36 AM.


  2. #2
    RaGEZONER habib10 is offline
    MemberRank
    Nov 2009 Join Date
    AnywereLocation
    778Posts

    Re: [PHP]Calculator

    posting twice lol

  3. #3
    Account Upgraded | Title Enabled! StrongFaith is offline
    MemberRank
    Aug 2010 Join Date
    .PHP filesLocation
    268Posts

    Re: [PHP]Calculator

    O.O ? i am very sorry , ill delete the other thread now!

    ---------- Post added at 11:34 AM ---------- Previous post was at 11:31 AM ----------

    deleted ,
    back on topic !

  4. #4
    Ginger by design. jMerliN is offline
    MemberRank
    Feb 2007 Join Date
    2,497Posts

    Re: [PHP]Calculator

    Don't see the point of this.

  5. #5
    Account Upgraded | Title Enabled! StrongFaith is offline
    MemberRank
    Aug 2010 Join Date
    .PHP filesLocation
    268Posts

    Re: [PHP]Calculator

    Well i released it for math noobs XD!

    another source : (from stracht) :
    PHP Code:
    <title>Calculator</title>
    <h1>Calculator - Coded by StronGCoder</h1>
    <form action="/calculator/index.php" method="post">
    <input type="text" name="x" value="Fill the number">
    <select name=operator>
    <option>Choose the operator :</option>
    <option>+</option>
    <option>-</option>
    <option>*</option>
    <option>/</option>
    </select>
    <input type="text" name="y" value="Fill the number">
    <input type="submit" value=Calculate>

    <?php
    if($_POST["x"] and $_POST["y"] == "Fill the number")
    {
    echo 
    "<b><br>Fill all fields please.</b>";
    }

    if(
    $_POST["operator"] == "Choose the operator :")
    {
    echo 
    "<b><br>Fill the operator too<br>";
    }

    if(!
    $_POST["x"] and !$_POST["y"])
    {
    echo 
    "<b>Fill all fields please.</b>";
    }

    if(!
    $_POST["operator"])
    {
    echo 
    "<br><br>";
    echo 
    "<b>The result will show here.</b>";
    }

    elseif(
    $_POST["operator"] == "+")
    {
    echo 
    "<br><br>";
    echo 
    $_POST["x"] . " + " $_POST["y"] ;
    echo 
    " = ";
    echo 
    $_POST["x"] + $_POST["y"];
    }

    elseif(
    $_POST["operator"] == "-")
    {
    echo 
    "<br><br>";
    echo 
    $_POST["x"] . " - " $_POST["y"] ;
    echo 
    " = ";
    echo 
    $_POST["x"] - $_POST["y"];
    }

    elseif(
    $_POST["operator"] == "*")
    {
    echo 
    "<br><br>";
    echo 
    $_POST["x"] . " * " $_POST["y"] ;
    echo 
    " = ";
    echo 
    $_POST["x"] * $_POST["y"];
    }

    elseif(
    $_POST["operator"] == "/")
    {
    echo 
    "<br><br>";
    echo 
    $_POST["x"] . " / " $_POST["y"] ;
    echo 
    " = ";
    echo 
    $_POST["x"] / $_POST["y"];
    }

    ?>
    Last edited by StrongFaith; 23-11-10 at 03:18 PM.

  6. #6
    Ginger by design. jMerliN is offline
    MemberRank
    Feb 2007 Join Date
    2,497Posts

    Re: [PHP]Calculator

    winkey+r 'calc'

    Better for "math noobs."

  7. #7
    ex visor Aaron is offline
    MemberRank
    May 2007 Join Date
    MichiganLocation
    4,028Posts

    Re: [PHP]Calculator

    This is so simple. Lol

  8. #8
    Hm. foxx is offline
    MemberRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,257Posts

    Re: [PHP]Calculator

    hopeless..

  9. #9
    Account Upgraded | Title Enabled! StrongFaith is offline
    MemberRank
    Aug 2010 Join Date
    .PHP filesLocation
    268Posts

    Re: [PHP]Calculator

    Quote Originally Posted by Aaron View Post
    This is so simple. Lol
    Quote Originally Posted by StrongFaith
    Hello Ragezoners , i made a calculator , its VERY SIMPLE tho , dont flame me.
    if u can read..

    Quote Originally Posted by foxx View Post
    hopeless..
    ur opinion..
    Quote Originally Posted by jMerliN View Post
    winkey+r 'calc'

    Better for "math noobs."
    i wanted to show it i made so..

  10. #10
    Ass > Tits Lapje is offline
    MemberRank
    Feb 2009 Join Date
    nullLocation
    1,879Posts

    Re: [PHP]Calculator

    Guys, this is the showcase. Let the guy have his minute of fame yah? Everyone starts simple.

  11. #11
    Hm. foxx is offline
    MemberRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,257Posts

    Re: [PHP]Calculator

    Quote Originally Posted by StrongFaith View Post
    Hello Ragezoners , i made a calculator , its VERY SIMPLE tho , dont flame me.
    so here it is !
    PHP Code:
    <h1>Simple calculator - Usable</h1>
    <h3>Source by foxx - thank you and edited by StronGCoder</h3>
    <?php
    // source by foxx - thanks!
    // edited by strong
    // advanced calculator coming soon!
    $result "";
    if (isset(
    $_POST['val'])) {
        
    $val = (float)$_POST['val'];
        
    $val2 = (float)$_POST['val2'];

        if (!
    $val and $val2) {
            
    $result .= "<p>Fill all fields , please!</p>";
        }

        
        if (!
    $result) {
            switch (
    $_POST['operator']) {
                case 
    "sum":
                    
    $result $val.'+'.$val2.' = '.$val+$val2;
                    break;
                case 
    "sub":
                    
    $result $val.'-'.$val2.' = '.$val-$val2;
                    break;    
                case 
    "mul":
                    
    $result $val.'*'.$val2.' = '.$val*$val2;
                    break;    
                case 
    "div":
                    
    $result $val.'/'.$val2.' = '.$val/$val2;
                    break;    
            }
        }
    }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cz" lang="cz"> 
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="Content-Language" content="en" />

        <title>Calculator by StronGCoder</title>
    </head>

    <body>
        <form method="post" action="/calculator/index.php">
            <dl>
                <label for="val"></label>
                <input type="text" name="val" id="val" value='First number' />
                
                <label for="operator"></label>
                
                    <select name="operator" id="operator">
                        <option value="Choose">Choose one :</option>                    
                        <option value="sum">+</option>
                        <option value="sub">-</option>
                        <option value="mul">*</option>
                        <option value="div">/</option>
                    </select>
                </dd>
                
                <label for="val2"></label>
                <input type="text" name="val2" id="val2" value='Second number' />
            
                <input type="submit" name="submit" value='Calculate' />

            </dl>
        </form>

        <?php
            
    echo $result;
        
    ?>
    </body>

    </html>


    credits
    50% - foxx - the base source
    50% - me - coding , fixing , editing !
    thanks!
    To repeat what I've said the in the other thread.

    There is not a single thing you've "fixed", in fact, you've, sadly, fokked it up.

    To go through it.
    PHP Code:
    <h1>Simple calculator Usable</h1>
    <
    h3>Source by foxx thank you and edited by StronGCoder</h3
    this shouldn't be there, not before the <html> tag, not before <?php ?>

    PHP Code:
        if (!$val and $val2) {
            
    $result .= "<p>Fill all fields , please!</p>";
        } 
    This doesn't make sense, it would throw error ONLY if you didn't fill value 1 but you did fill value 2.

    PHP Code:
        <form method="post" action="/calculator/index.php"
    "/" would be perfectly fine

    PHP Code:
            <dl>
                <
    label for="val"></label>
                <
    input type="text" name="val" id="val" value='First number' />
                
                <
    label for="operator"></label>
                
                    <
    select name="operator" id="operator">
                        <
    option value="Choose">Choose one :</option>                    
                        <
    option value="sum">+</option>
                        <
    option value="sub">-</option>
                        <
    option value="mul">*</option>
                        <
    option value="div">/</option>
                    </
    select>
                </
    dd>
                
                <
    label for="val2"></label>
                <
    input type="text" name="val2" id="val2" value='Second number' />
    </
    dl
    <dl> is a definiton list, it wrap dt and dd elements, it requires at least one dt, you've deleted all dt and dd and only left one dd closing tag (</dd>), so it wouldn't validate and probably will be fokked up in most of the browsers..

    labels are.. well labels, why leave them there when you deleted the text inside them?

    You see, you took my source and messed it up, that's why I said hopeless.

    No need to give me any credit there, really, someone could of thought I made this mess.
    Last edited by foxx; 24-11-10 at 07:51 AM.

  12. #12
    Account Upgraded | Title Enabled! StrongFaith is offline
    MemberRank
    Aug 2010 Join Date
    .PHP filesLocation
    268Posts

    Re: [PHP]Calculator

    foxx , everything works perfectly , do not start.
    not really messed , its better than ur source. labels and etc aint needed , i deleted them and connected everything , without them everything is working perfectly , same as with them
    PHP Code:
    if (!$val and $val2) {
            
    $result .= "<p>Fill all fields , please!</p>";
        } 
    None uses calculator to test errors , but to calculate !

    "/" is perfectly fine >:) !

    *</dd> </dl>* WTF r u talking about ? theres no <dd> and <dl> or </dd> and </dl>
    u added those urself on the code to flame me , heres the real :
    PHP Code:
    <h1>Simple calculator - Usable</h1>
    <h3>Source by foxx - thank you and edited by StronGCoder</h3>
    <?php
    // source by foxx - thanks!
    // edited by strong
    // advanced calculator coming soon!
    $result "";
    if (isset(
    $_POST['val'])) {
        
    $val = (float)$_POST['val'];
        
    $val2 = (float)$_POST['val2'];

        if (!
    $val and $val2) {
            
    $result .= "<p>Fill all fields , please!</p>";
        }

        
        if (!
    $result) {
            switch (
    $_POST['operator']) {
                case 
    "sum":
                    
    $result $val.'+'.$val2.' = '.$val+$val2;
                    break;
                case 
    "sub":
                    
    $result $val.'-'.$val2.' = '.$val-$val2;
                    break;    
                case 
    "mul":
                    
    $result $val.'*'.$val2.' = '.$val*$val2;
                    break;    
                case 
    "div":
                    
    $result $val.'/'.$val2.' = '.$val/$val2;
                    break;    
            }
        }
    }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cz" lang="cz"> 
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="Content-Language" content="en" />

        <title>Calculator by StronGCoder</title>
    </head>

    <body>
        <form method="post" action="/calculator/index.php"> 
                <label for="val"></label>
                <input type="text" name="val" id="val" value='First number' />
                
                <label for="operator"></label>
                
                    <select name="operator" id="operator">
                        <option value="Choose">Choose one :</option>                    
                        <option value="sum">+</option>
                        <option value="sub">-</option>
                        <option value="mul">*</option>
                        <option value="div">/</option>
                    </select>
                
                
                <label for="val2"></label>
                <input type="text" name="val2" id="val2" value='Second number' />
            
                <input type="submit" name="submit" value='Calculate' />

           
        </form>

        <?php
            
    echo $result;
        
    ?>
    </body>

    </html>
    @lapje
    i already code advanced , but coding calculator is simple , so the calculator is simple to !
    Last edited by StrongFaith; 24-11-10 at 10:35 AM.

  13. #13
    Hm. foxx is offline
    MemberRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,257Posts

    Re: [PHP]Calculator

    Wow, you actually are retarded.

    So wait, I tell you what exactly is wrong with your code and why and you repeat with "my code it better then yours", dude lol.

    Fucking habbo.

    ---------- Post added at 10:54 AM ---------- Previous post was at 10:36 AM ----------

    Lmao. You are really fucking idiot, yea, now there are no dl and dd, because you deleted those two you left there.

    Like it doesn't say "Last edited by StrongFaith; 13 Minutes Ago at 10:36 AM."

    Jesus you are honestly moron lol.

    ---------- Post added at 10:59 AM ---------- Previous post was at 10:54 AM ----------

    Were I still mod here you would already be banned for pure stupidity.

  14. #14
    Account Upgraded | Title Enabled! StrongFaith is offline
    MemberRank
    Aug 2010 Join Date
    .PHP filesLocation
    268Posts

    Re: [PHP]Calculator

    LOL , i didnt edit . i edited my caps on the text !

    ---------- Post added at 11:06 AM ---------- Previous post was at 11:04 AM ----------

    FUCK THE FUCKING JESUS ! ALLAH created us , MUSLIM is the right religion , stop editing MUSLIM religion and making noob religions !

    ---------- Post added at 11:07 AM ---------- Previous post was at 11:06 AM ----------

    Jesus is called in real - Isa Alei Selam . So stop changing his name !

  15. #15
    Hm. foxx is offline
    MemberRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,257Posts

    Re: [PHP]Calculator

    But since I'm not a mod anymore and I got nothing to do, let's flame you.

    Let's say I'm someone who downloaded both sources and tried them.

    1) html validity
    yours: http://download.foxx.f13.cz/retards/html.png 7 errors 7 warning

    mine: http://download.foxx.f13.cz/retards/html2.png valid

    2) after press without filling anything
    yours: http://download.foxx.f13.cz/retards/press.png not found error because you used absolute path for your form action

    mine: http://download.foxx.f13.cz/retards/press2.png throws warning because you didn't fill anything

    3) filled one field
    your: http://download.foxx.f13.cz/retards/onefill.png nothing happens, user is confused don't know what happened

    mine: http://download.foxx.f13.cz/retards/onefill2.png throw warning that you forgot to fill the second value

    4) filled only second value
    yours: http://download.foxx.f13.cz/retards/fillsecond.png says fill all fields, but it didn't when I filled first and didn't fill second, strange isn't it !

    mine: http://download.foxx.f13.cz/retards/fillsecond2.png warns user that he forgot to fill the first value


    5) calculating
    works fine on both, because it's the only part you didn't fuck with.

    ---

    So what exactly did you FIX on my script and what made it BETTER.

    Or whatever, you little habbo brain can't understand half of what I've writte here anyway..

    ---------- Post added at 11:18 AM ---------- Previous post was at 11:13 AM ----------

    Quote Originally Posted by StrongFaith View Post
    LOL , i didnt edit . i edited my caps on the text !

    ---------- Post added at 11:06 AM ---------- Previous post was at 11:04 AM ----------

    FUCK THE FUCKING JESUS ! ALLAH created us , MUSLIM is the right religion , stop editing MUSLIM religion and making noob religions !

    ---------- Post added at 11:07 AM ---------- Previous post was at 11:06 AM ----------

    Jesus is called in real - Isa Alei Selam . So stop changing his name !
    No, you didn't edit anything, right right, you forgot you already posted this once, yesterday



    Dude you are such a faggot.


    And about that religious stuff, there's only one thing I can say.




Page 1 of 2 12 LastLast

Advertisement