We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16430
    • 217 Posts
    Hi, I have snippet code:
    $sent_id = (int) $_POST['favorite_page'];
    if ($sent_id > 100000 or $sent_id == 0) return; 
    $id = $modx->resource->get('id'); //current id


    But warning in error log:
    WARN @ /core/cache/includes/elements/modsnippet/75.include.cache.php : 3) PHP notice: Undefined index: favorite_page

    What wrong in the code?
    thanks...
      • 3749
      • 24,544 Posts
      Whatever is setting the $_POST variables is not setting the $_POST['favorite_page'] variable.

      Normally, this would come from a form with something like this:

      <form ... >
         <input type="text" name="favorite_page" ... >
      </form>


      Check the "name" of the field in the form to make sure it matches the code.

      You could also add this line to the snippet:

      $modx->log(modX::LOG_LEVEL_ERROR, print_r($_POST, true));


      That will print the $_POST array to the MODX error log so you can see what's actually being sent.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting