You are here: Re: Problem combining validation and templates « PHP Programming Language « IT news, forums, messages
Re: Problem combining validation and templates

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."\"/>";
}
}

?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация