Posted by Phil Latio on 05/17/07 03:01
Got it working. Damn obvious to use isSet, can't think why I did not think
of it before. Not exactly happy with the code but at least I can now think
how to do this more efficiently since it works.
Cheers
Phil
<?php
//testpage02.php
$newTextBox = new myTextBox("username", "standardTextBox");
$newSubmitButton = new mySubmitButton("Submit");
if (!isSet($_POST['username']))
{
include ("testpage02.tpl.php");
exit;
}
if (!empty($_POST['username']))
{
echo "Success";
exit;
}
else
{
$newTextBox->setStyle("errorTextBox");
include ("testpage02.tpl.php");
exit;
}
class myTextBox
{
private $textboxName;
private $style;
function __construct($textboxName, $style)
{
$this->textboxName = $textboxName;
$this->style= $style;
}
function setStyle($style)
{
$this->style= $style;
}
function getTextBox()
{
$line = "<input type=\"text\" ";
$line.= "name=\"";
$line.= $this->textboxName;
$line.= "\" ";
$line.= "class=\"";
$line.= $this->style;
$line.= "\" />";
return $line;
}
}
class mySubmitButton
{
private $value;
function __construct($value)
{
$this->value = $value;
}
function getSubmitButton()
{
return "<input type=\"submit\" value=\"".$this->value."\"/>";
}
}
?>
[Back to original message]
|