1
Thulani
Re: please help with Xoops classes using xoopshandlers
  • 2012/4/24 14:26

  • Thulani

  • Just popping in

  • Posts: 3

  • Since: 2012/4/23


I'm happy thanks it works.



2
Thulani
Re: please help with Xoops classes using xoopshandlers
  • 2012/4/24 14:24

  • Thulani

  • Just popping in

  • Posts: 3

  • Since: 2012/4/23


Thank somuch it worked pretty well fine :)



3
Thulani
please help with Xoops classes using xoopshandlers
  • 2012/4/23 10:39

  • Thulani

  • Just popping in

  • Posts: 3

  • Since: 2012/4/23


*My module folder name is "tutorial" ,and my class name is "software" ,and my php admin database name is "software_myform"..I am trying to insert data into a form.

<?php
//Capture Softwares
require('../../mainfile.php');
require(
XOOPS_ROOT_PATH.'/header.php');


global 
$xoopsTpl$xoopsOption$xoopsUser;


if(!(
is_object($xoopsUser))){

      echo(
'you need to be logged in to Capture Softwares.');
   }

$op ='';


if(isset(
$_POST['op'])) {
    
$op $_POST['op'];
}



switch(
$op) {
    
        case 
'post':
        
       
$SoftwaresSoftwareHandler =& xoops_getModuleHandler('software','tutorial');
        
        
$software_id $_POST['software_id'];

        if (
$Software_id == 0) {
            
$Softwareobj =  $SoftwaresSoftwareHandler->create();
        }
   

        else {
            
$Softwareobj $SoftwaresSoftwareHandler->get($software_id);
        }   

        
$Softwareobj->setVar("software_id"$_POST['software_id']);
        
$Softwareobj->setVar("software_title"$_POST['software_title']);
        
$Softwareobj->setVar("publisher"$_POST['publisher']);
        
$Softwareobj->setVar("license_key"$_POST['license_key']);
        
$Softwareobj->setVar("total_no_licenses"$_POST['total_no_licenses']);
        
$Softwareobj->setVar("S_Date"time()); 
        
$Softwareobj->setVar("userid"$GLOBALS['xoopsUser']->getVar("uid"));
       } 
         
     if(!(
$SoftwaresSoftwareHandler->insert($Softwareobj))){
         echo 
"Error";
  }     else {
          echo 
"successful";
   }  


    if(
$SoftwareObj->isNew()) {  //update User posts
                
if(is_object($xoopsUser)) {
                    
$uid $xoopsUser->GetVar('uid');
                    if (
$uid 0) {
                        
$member_handler =& xoops_gethandler('member');
                        
$poster =& $member_handler->getUser($uid);
                        if (
is_object($poster)) {
                            
$member_handler->updateUserByField($poster'posts'$poster->getVar('posts') + 1);
                        }
                    }
                }

            }  

 return 
true;


require(
XOOPS_ROOT_PATH.'/footer.php');
?>

//here is my class:
<?php

if (!defined("XOOPS_ROOT_PATH")) { die('root path not defined');
}
 
    
class 
tutorialsoftware extends XoopsObject {
     
     var 
$_groups_read null;
  
      function 
tutorialsoftware()
    {
        
$this->__construct();
    }
   
     function 
__construct()
    {
       
// $this->XoopsObject();
        
$this->initVar('software_id',          XOBJ_DTYPE_INT);
        
$this->initVar('software_title',       XOBJ_DTYPE_TXTBOX,null,255);
        
$this->initVar('publisher',            XOBJ_DTYPE_TXTBOX,null,255);
        
$this->initVar('license_key',          XOBJ_DTYPE_TXTBOX,null,255);
        
$this->initVar('total_no_licenses',    XOBJ_DTYPE_INT);
        
$this->initVar('S_Date',               XOBJ_DTYPE_INT);
        
$this->initVar('userid',               XOBJ_DTYPE_INT);
 
    }

 }   
  

  class 
tutorialsoftwareHandler extends XoopsPersistableObjectHandler
{

   function 
SoftwaresSoftwareHandler(&$db)
    {
        
$this->__construct($db);
    } 
  
    function 
__construct(&$db
    {
        
parent::__construct($db,'software_myform','tutorialsoftware''software_id');
    }
}
?>


//here is my form

<html>
<
head>
<
body>
<
form name="form" method="post" action="capture.php">
  <
table width="400" border="0">
    <
tr>
      <
td align="right">Software Title</td>
      <
td><input type="text" name="software_title"></td>
    </
tr><tr>
      <
td align="right">Purchase</td>
      <
td><input type="text" name="publisher"></td>
    </
tr><tr>
      <
td align="right">License key</td>
      <
td><input type="text" name="license_key"></td>
    </
tr><tr>
      <
td align="right">Total no licenses</td>
      <
td><input type="text" name="total_no_licenses"></td>
    </
tr><tr>
      
     
      <
td>
     <
input type="submit" name="submit" value="submit"></td>
       
 </
table>
</
head>
</
body>
</
form>








TopTop



Login

Who's Online

154 user(s) are online (102 user(s) are browsing Support Forums)


Members: 0


Guests: 154


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits