We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23383
    • 138 Posts
    Hello,

    I’d like to develop a module, a sort of wizard.
    I wrote this :

    include_once $MLpath."ML.inc.php";
    $object=new ML($MLpath);
    
    //I'm coming from manager
    if(empty($_POST))
    {
    $object->populateFields($parentids); //I write some default fields values in the adminpage1 form
    $object->AdminPage("1"); //show adminpage1
    }
    
    if(isset($_POST['cancel'])) 
    {
    $object->populateFields($parentids);
    $object->AdminPage("1");
    }
    
    //Ok, go to adminpage2
    if(isset($_POST['submit']))
    {
    $object->checkfields();
    unset($_POST['submit']);
    $object->AdminPage("2");
    }
    
    //Ok, go to adminpage3
    if(isset($_POST['submit2']))
    {
    $object->sendML(); //Problem : doesn't remember the results of checkfields !
    $object->AdminPage("3");
    }
    


    In the admin page method, I "echo " some HTML page, with a form, and the action of the form is :
    action=""

    So, I’m coming back to the module code. But the problem is : the instance $object doesn’t remember what it was appening beforce, it’s something like each time the modules creates another $object. Is there a way to keep the variables of my $object ?
      • 27376
      • 576 Posts
      Try setting and retrieving your settings through the $_SESSION variable array.

      Alternatively, you could try this:
      <?php
      $_SESSION['myCustomModuleObject'] = serialize($object);


      Then in your script, check to see if the session contains your object, and then [tt]unserialize()[/tt] AFTER you’ve declared the class it belongs to.

      [tt]serialize()[/tt]
        • 23383
        • 138 Posts
        That’s what I’ve done and it’s working, thank you.