My first codes in php

Results 1 to 9 of 9
  1. #1
    Good Guy George qet123 is offline
    MemberRank
    Apr 2009 Join Date
    DesertLocation
    1,432Posts

    My first codes in php

    Insert Text in TextBox:

    Click Sumbit to Display what's wrriten:

    PHP Code:
    <?php
        
    require('George.php');
        
    $George = new George();

        
    /* Output message (popup/normal) */
        
    $George->Output("Welcome to George Class"02552556000);    
        
        
        
    /* Connect to website by name */
        //$George->ConnectTo("http://www.google.com");
        
        /* Label */
        
    $George->Output("Insert Text"2550065120);
        
        
    /* Textbox */
        //$George->TextBox("TextBox1", 604, 35);
        
        /* Button */
        
    $George->Button("TextBox1""Sumbit"6103665360);
        
    $George->Output2($TextBox1);
    ?>
    PHP Code:
    <?php
    class George
    {
        function 
    RGBToHex($r$g$b
        {
            if((
    $r == "0") && ($g == "0") && ($b == "0")) return '#FFFFFF';
            
    $hex "#";
            
    $hex.= str_pad(dechex($r), 2"0"STR_PAD_LEFT);
            
    $hex.= str_pad(dechex($g), 2"0"STR_PAD_LEFT);
            
    $hex.= str_pad(dechex($b), 2"0"STR_PAD_LEFT);
            return 
    $hex;
        }
        function 
    Output($szText$r$g$b$left$top)
        {
            
    $color $this->RGBToHex($r$g$b);
            echo 
    "<font color='$color' style='position:absolute; left:$left; top:$top;'>$szText</font>";
        }
        function 
    Output2($szText)
        {
            echo 
    "<script type='text/javascript'>alert('{$szText}');</script>";
        }
        function 
    ConnectTo($szText)
        {
            
    header("Location: $szText");
        }
        function 
    TextBox($szName$left$top)
        {
            echo
            
    "<form method='post' action=''>".
            
    "<input type='text' name='{$szName}' id='text' style='position:absolute; left:$left; top:$top;'/>".
            
    "</form>";
        }
        function 
    Button($szName$szSecondName$left$top$left2$top2)
        {    
            echo
            
    "<form method='post'>".
            
    "<input type='text' name='{$szName}' id='text' style='position:absolute; left:$left; top:$top;'/>".
            
    "<input type='submit' name='Enter' id='Enter' value='{$szSecondName}' style='position:absolute; left:$left2; top:$top2;'/>".
            
    "</form>";
        }
    }
    ?>


  2. #2
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: My first codes in php

    PHP Code:
        function RGBToHex($r$g$b)  {
            if (
    $r == && $g == && $b == 0) {
                return 
    "#FFFFFF";
            }
            
            return 
    "#" sprintf("%02X%02X%02X"dechex($r), dechex($g), dechex($b));
        } 
    No need to use padding there. Other than that, looks good for a first class.

  3. #3
    Account Upgraded | Title Enabled! AngraMainyu is offline
    MemberRank
    May 2011 Join Date
    445Posts

    Re: My first codes in php

    You're going to run into problems with

    PHP Code:
    function ConnectTo($szText)
        {
            
    header("Location: $szText");
        } 
    If that's not the first call in your script (header()) it won't work, and might throw an error of some kind. Otherwise pretty good for a first project, especially by RZ standards.

  4. #4
    Intelligent DoucheBag jur13n is offline
    MemberRank
    Jan 2008 Join Date
    Zwolle,Location
    1,946Posts

    Re: My first codes in php

    what is "sumbit"?

  5. #5
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: My first codes in php

    Quote Originally Posted by jur13n View Post
    what is "sumbit"?
    A cool way of submitting.

  6. #6
    Intelligent DoucheBag jur13n is offline
    MemberRank
    Jan 2008 Join Date
    Zwolle,Location
    1,946Posts

    Re: My first codes in php

    Quote Originally Posted by Solaire View Post
    A cool way of submitting.
    It's like using numbers as variables k

  7. #7
    • ♠️​ ♦️ ♣️ ​♥️ • שเ๒єtгเ๒є is offline
    MemberRank
    Mar 2012 Join Date
    917Posts

    Re: My first codes in php

    Quote Originally Posted by jur13n View Post
    It's like using numbers as variables k
    definitely not ^^

  8. #8
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: My first codes in php

    Quote Originally Posted by jur13n View Post
    It's like using numbers as variables k
    No, because using numbers as a variable would throw an error. Miss-spelling something in HTML won't.

  9. #9
    C:\ WizCoder is offline
    MemberRank
    Aug 2010 Join Date
    JapanLocation
    703Posts

    Re: My first codes in php

    lol qet you actually started doing PHP, took long enough.



Advertisement