Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

My first codes in php

Good Guy George
Loyal Member
Joined
Apr 12, 2009
Messages
1,260
Reaction score
239
Insert Text in TextBox:
pkOX2s6 - My first codes in php - RaGEZONE Forums

Click Sumbit to Display what's wrriten:
ULSByGM - My first codes in php - RaGEZONE Forums

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

	/* Output message (popup/normal) */
	$George->Output("Welcome to George Class", 0, 255, 255, 600, 0);	
	
	
	/* Connect to website by name */
	//$George->ConnectTo("http://www.google.com");
	
	/* Label */
	$George->Output("Insert Text", 255, 0, 0, 651, 20);
	
	/* Textbox */
	//$George->TextBox("TextBox1", 604, 35);
	
	/* Button */
	$George->Button("TextBox1", "Sumbit", 610, 36, 653, 60);
	$George->Output2($TextBox1);
?>

PHP:
<?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>";
	}
}
?>
 

Attachments

You must be registered for see attachments list
Praise the Sun!
Loyal Member
Joined
Dec 4, 2007
Messages
2,502
Reaction score
986
PHP:
    function RGBToHex($r, $g, $b)  {
        if ($r == 0 && $g == 0 && $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.
 
Elite Diviner
Joined
May 30, 2011
Messages
443
Reaction score
95
You're going to run into problems with

PHP:
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.
 
Back
Top