Sourceview :: Discussion

Discussion in 'GR Classic Archive' started by spartan117, Jan 13, 2008.

  1. .ToMMy

    .ToMMy Well-Known Member

    Age:
    35
    Posts:
    438
    Likes Received:
    0
    Joined:
    Jan 4, 2007
    Location:
    Arizona
    Should we make a bank?
    Maybe like 50% goes to the person who does the work... and 50% goes to the bank?
     
  2. .ToMMy

    .ToMMy Well-Known Member

    Age:
    35
    Posts:
    438
    Likes Received:
    0
    Joined:
    Jan 4, 2007
    Location:
    Arizona
    Simple Calculator Code I just wrote.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Simple Calculator © Tommyfx.com</title>
    </head>
    
    <body>
    <div align="center">
    <font face="Tahoma" size="2pt">
    <form name="form1" action="calctest.php" method="post">
    First Number: <input type="text" name="first" />
    
    
    
    Add: <input type="radio" name="add" />
    
    Subtract: <input type="radio" name="sub" />
    
    Multiply: <input type="radio" name="mult" />
    
    Divide: <input type="radio" name="div" /> 
    
    
    
    Second Number: <input type="text" name="second" />
    
    
    
    <input name="submit" type="submit" value="Submit" alt="Submit" />
    </form>
    
    
    
    
    The solution is: 
    <?php
    $add = $_POST[add];
    $sub = $_POST[sub];
    $mult = $_POST[mult];
    $div = $_POST[div];
    $first = $_POST[first];
    $second = $_POST[second];
    
    if ($_POST[add] == true) {
    $total = $first + $second;
    echo $total;
    }
    if ($_POST[sub] == true) {
    $total = $first - $second;
    echo $total;
    }
    if ($_POST[mult] == true) {
    $total = $first * $second;
    echo $total;
    }
    if ($_POST[div] == true) {
    $total = $first / $second;
    echo $total;
    }
    ?> 
    </font>
    </div>
    </body>
    </html>
    Live preview: http://tommyfx.com/calctest.php
     
  3. travmanx

    travmanx Senior Member

    Age:
    37
    Posts:
    733
    Likes Received:
    0
    Joined:
    Oct 3, 2007
    Location:
    USA
    Why not make it simpilar, instead of using radio buttons, create 4 differnt submit buttons add subtract, ect...

    Or better yet, have the user type it in, but set an array for keys that can be used

    $keys = array('+','-','*','/');
    if($_POST['mathbox2'] /= $keys){
    die();
    } else {
    echo $_POST['mathbox1'].$_POST['mathbox2'].$_POST['mathbox3'];
    }
    Simplified the php code down about 4 times the size of yoru original lol

    :D
     
  4. .ToMMy

    .ToMMy Well-Known Member

    Age:
    35
    Posts:
    438
    Likes Received:
    0
    Joined:
    Jan 4, 2007
    Location:
    Arizona
    That works too..
    lol

    You have to remember I am new to PHP, so I tend to do things the hard way... but I never though about using an array...
     
  5. travmanx

    travmanx Senior Member

    Age:
    37
    Posts:
    733
    Likes Received:
    0
    Joined:
    Oct 3, 2007
    Location:
    USA
    Thats what this crew is about :) helping
     
  6. spartan117

    spartan117 Senior Member

    Age:
    35
    Posts:
    1,794
    Likes Received:
    0
    Joined:
    Oct 31, 2005
    Location:
    San Antonio, TX, USA
    Yeah I suppose we could create a shop. I'm just saying you guys shouldn't be too disappointed if we don't get that much business. Also, why would we set aside 50%? There aren't really many web design resources floating around GR to buy, and it would be kind of weird for us to be buying signatures and stuff. I think we should just split up the money.

    But for the pack, if we included:
    PHP scripts
    a couple coded templates
    a couple myspace DIV overlays
    and a page with credits and sites they can visit for more help

    I think that would be pretty good. If you guys want me to create a shop, let me know and I'll get that done.

    I'll listen to what you guys want. It's your crew as much as it is mine.
     
  7. travmanx

    travmanx Senior Member

    Age:
    37
    Posts:
    733
    Likes Received:
    0
    Joined:
    Oct 3, 2007
    Location:
    USA
    I agree. The owner of the script should get full credits. Hoping to get this damn guestbook done in the next day or so. I will be selling or atleast try to sell on here. lol
     
  8. frontmill

    frontmill Senior Member

    Age:
    37
    Posts:
    3,007
    Likes Received:
    0
    Joined:
    May 30, 2005
    Location:
    The Netherlands
    Let's just evenly spread the credits among all people that cooperated. Have you guys got msn btw?
     
  9. travmanx

    travmanx Senior Member

    Age:
    37
    Posts:
    733
    Likes Received:
    0
    Joined:
    Oct 3, 2007
    Location:
    USA
    Yeah, that would be a group project. But I'm saying single projects like my Guestbook, I did myself, so I should get those credits... :D
     
  10. travmanx

    travmanx Senior Member

    Age:
    37
    Posts:
    733
    Likes Received:
    0
    Joined:
    Oct 3, 2007
    Location:
    USA
    We've been active 2 weeks, shouldnt we get our own forum section?
     
  11. travmanx

    travmanx Senior Member

    Age:
    37
    Posts:
    733
    Likes Received:
    0
    Joined:
    Oct 3, 2007
    Location:
    USA
    Well, I'm stuck... I am running my install.php, and I can create 3 table then it poops out on me saying Mysql Query was Empty...
    Here is the table and info...

    $login = "CREATE TABLE `".$_POST['login']."` (
    `id` int(11) NOT NULL auto_increment,
    `username` char(20) NOT NULL default '',
    `password` char(32) NOT NULL default '',
    `cookie` char(32) NOT NULL default '',
    `session` char(32) NOT NULL default '',
    `ip` char(15) NOT NULL default '',
    PRIMARY KEY (`id`),
    UNIQUE KEY `username` (`username`)
    ) TYPE=MyISAM";
    mysql_query($login) or die(mysql_error());

    Anyone know?? :mad:
     
  12. spartan117

    spartan117 Senior Member

    Age:
    35
    Posts:
    1,794
    Likes Received:
    0
    Joined:
    Oct 31, 2005
    Location:
    San Antonio, TX, USA
    We need to be active a month, not two weeks
     
  13. travmanx

    travmanx Senior Member

    Age:
    37
    Posts:
    733
    Likes Received:
    0
    Joined:
    Oct 3, 2007
    Location:
    USA
    Ah ok, I misread.
     
  14. alrocks334

    alrocks334 Well-Known Member

    Posts:
    677
    Likes Received:
    0
    Joined:
    Jan 23, 2005
    I know this was from a couple posts back, but I just want to clear something up, because it's bugging me. That code right there isn't a calculator, it will display "12/3", not "4". You are confusing strings with numbers. The period function implicitly casts variables into strings, then concatenates them. It does not perform a mathematical operation based on the character within a string. Tommy's original calculator is done correctly, as the + function makes everything it can into a number before addition, and the result will be as expected.

    More alarming though is that if you were to ever implement this modified calculator into anything more permanent, you would be opening a magnificent XSS (cross-site scripting) security loophole into your site. I think it's important that we, as the gamerenders web design group, don't go around spreading messy, non-functional code.
     
  15. iPro

    iPro Senior Member

    Age:
    34
    Posts:
    2,662
    Likes Received:
    0
    Joined:
    Jan 19, 2006
    Location:
    United States

Share This Page