Calling a class function based on function.
Posted: Thu Oct 19, 2006 12:24 am
Hi guys
Got a problem and I hope someone can help.
Basically i,m designing a form handler class.
The construct takes a form name as a value, based on that value, I want to run a pre-defined class function.
Is this possible?
Here's what I have so far ...
Thx guys
Got a problem and I hope someone can help.
Basically i,m designing a form handler class.
The construct takes a form name as a value, based on that value, I want to run a pre-defined class function.
Is this possible?
Here's what I have so far ...
Code: Select all
<?php
class form_handler {
var $form_name;
var $form_state;
var $form_error_count = 0;
var $form_errors_array = array();
function __construct($formname) {
$this->form_name = $formname . '_form.tpl.php';
<---code here to call $this->_registration();--->
}
function _showform() {
include './templates/' . $this->form_name;
}
function _registration() {
if (!isset($_POST['submit'])) {
$this->_showform();
}
elseif (isset($_POST['submit'])) {
$this->_form_val_required('name','password','email');
if (!$this->form_error_count == 0) {
$this->_showform();
}
}
}
function _form_val_required() {
$numargs = func_num_args();
for ($i = 0; $i <= $numargs - 1; $i++) {
if ($_POST[func_get_arg($i)] == "") {
$this->form_errors_array[func_get_arg($i)] = "<div class=\"formerror\">The field above is required!</div>\n";
$this->form_error_count++;
}
}
}
}
?>