Jump to content

lastkarrde

Members
  • Posts

    165
  • Joined

  • Last visited

    Never

Posts posted by lastkarrde

  1. Well, usually you can only access object properties if they are defined:

    <?php
    
    class Person
    {
      public $name;
      public $age;
      public $title = 'Sir';
    }
    
    $p = new Person();
    echo $p->title;
    //Sir
    
    $p->name = 'Atticus';
    echo $p->name;
    //Atticus
    
    $p->age = 48;
    echo $p->age;
    //48
    
    ?>

     

    The magic method __set() (usually combined with __get() ) allows you to define and access object properties dynamically.

     

    <?php
    
    class Person
    {
    
      public $data = array();
    
      public function __set($name, $value)
      {
        $this->data[$name] = $value;
      }
    
      public function __get($name)
      {
        if(isset($this->data[$name]))
        {
          return $this->data[$name];
        }
        else
        {
          echo 'NOT SET';
        }
      }
    
    }
    
    $z = new Person();
    
    echo $z->title;
    //NOT SET
    
    $z->name = 'Atticus';
    echo $z->name;
    //Atticus
    
    $z->age = 48;
    echo $z->age;
    //48
    
    ?>
    

  2. Howdy folks.

     

    I'm having some troubles with forms not submitting when they are included by an AJAX call.

     

    I have a page, <em>/add_many/</em> which just displays an HTML form. If I navigate to that page the form works as expected. However If i try and display that page in a dijit.Dialog modal (loaded via AJAX), the form will not submit.

     

    Below is my AJAX code

     

    addDialog = new dijit.Dialog({title: 'Add Reddit User', style: 'width:500px', preventCache:true});
    addDialog.attr('href', '/add_many/');
    addDialog.show();

     

    The form displays fine in the dijit.Dialog box, and I can enter information into it. However clicking the submit button does absolutely nothing.

    Any ideas?

     

    Thanks

  3. I've only worked with Paypal's API so I can only comment on that. They send a POST request to a script location that you specify (generally known as a postback). The POST request contains all of the information about the transaction (was it successful, etc).

     

    This will give you an idea on how to interpret the postback.

  4. Parsing XML is slow compared to a database SELECT.

     

    Set up your DB tables so that it represents the XML schema. Pull the XML file in, parse it, and save the relevant information in it to the database. That way every time you want to reference that data, your not parsing an XML file (which takes time).

     

    If your wanting to delete the old data, when you pull another/updated feed in, just do a DELETE where the timestamp is less than the current timestamp.

  5. A profile page is just made up of some database queries and forms (if you want to save other user data like location, date of birth etc). I suggest you spend time learning PHP and the basics of MySQL. Understand what your login and registration code is actually doing. Once you understand that, implementing user profiles will be trivial.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.