• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

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