Hi everyone.I am using xoops classes for the 1st time and it seems like I am not getting it right. I am creating a simple program to insert data into a table called capture_information. This is my code:
//for index.php
require('../../mainfile.php');
global $xoopsOption;
$xoopsOption['template_main']= 'main.html';
require(XOOPS_ROOT_PATH.'/header.php');
//////
$op = '';
if(isset($_POST['save'])){
$op = 'save';
}
if(isset($_POST['delete'])){
$op = 'delete';
}
switch($op){
case 'delete':
echo 'why u wana delete?';
case 'save':
$record_handler =& xoops_getModuleHandler('records','record');
$record_id = $_POST['record_id'];
if($record_id == 0){
//
$recordObj = $record_handler->create();
}
else{
//
$recordObj = $record_handler->get($record_id);
}
{
$recordobj->setVar("name",$_POST['name']);
$recordobj->setVar("email", $_POST['email']);
$recordobj->setVar("telephone", $_POST['telephone']);
$recordobj->setVar("address", $_POST['address']);
$recordobj->setVar("areacode", $_POST['areacode']);
$recordobj->setVar("time", time());
$recordobj->setVar("user_id", $GLOBALS['xoopsUser']->getVar("uid"));
}
if(!($record_handler->insert($recordObj)))
{
redirect_header(XOOPS_URL,2,'Error saving record');}
break;
}
require(XOOPS_ROOT_PATH.'/footer.php');
?>
//for the class called record under a module called record
if (!defined("XOOPS_ROOT_PATH")) {
die("XOOPS root path not defined");
}
class RecordRecord extends XoopsObject {
function RecordRecord() {
$this->__construct();
}
function __construct() {
$this->initVar("record_id", XOBJ_DTYPE_INT, null, false);
$this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false);
$this->initVar('email', XOBJ_DTYPE_TXTBOX, null, false);
$this->initVar("telephone", XOBJ_DTYPE_TXTBOX, null, false, 255);
$this->initVar('address', XOBJ_DTYPE_TXTBOX, null, false);
$this->initVar("areacode", XOBJ_DTYPE_TXTBOX, 0, false);
$this->initVar("time", XOBJ_DTYPE_INT, 0, false);
$this->initVar("user_id", XOBJ_DTYPE_INT, null, false, 15);
}
}
class RecordRecordsHandler extends XoopsPersistableObjectHandler {
var $recordList;
function RecordRecordsHandler(&$db)
{
$this->__construct($db);
}
function __construct(&$db) {
parent::__construct($db, 'capture_information', 'RecordRecord', 'record_id');
}
?>
when i click the save button it shows me a blank page.plz help