How to add the data from a checkbox as a meta key/pair

  • Unknown's avatar

    Hi All,

    How do i add the data from a checkbox as a meta key?? I tried googling alot , most of the google results pointed towards creating a meta box in the admin area. What i want is simple form processing if the user selects multiple value and these values are stored as part of the meta key for a given post. :P

    <form method = “post” action = “ppp.php”>
    <input type = “checkbox” name = “mycheck[]” value = “orange”>ORANGE
    <input type = “checkbox” name = “mycheck[]” value = “apple”>APPLE
    <input type = “checkbox” name = “mycheck[]” value = “banana”>BANANA
    <input type = “checkbox” name = “mycheck[]” value = “pear”>PEAR
    <input type = “checkbox” name = “mycheck[]” value = “gauva”>GUAVA
    <input type = “submit” name = “send” value = “SEND”>
    </form>

    i tried the following but don’t work..

    Do i need to do some serializing??

    add_post_meta($published_id, ‘META_mycheck’, $mycheck, true);

    And later do i extract the data using the get_post_data?? Do i need some foreach loop?

    Thanks, in advance..

  • Unknown's avatar

    The site linked to your name is empty – what is the URL of the site you are asking about?

    https://en.forums.wordpress.com/topic/7-things-to-know-before-posting-in-wordpresscom-forums?replies=1

    For more on the difference: http://support.wordpress.com/com-vs-org/

  • Unknown's avatar

    Hi Auxclass,

    My blog is not up because of that problem :(

    It should be a simple solution but i am a newbie here..

  • Unknown's avatar

    You are probably in the wrong forum that is why we want the url of your site to try and see if you are even in the right forum – this forum is for support of sites hosted on WordPress.COM

    Without the URL you are wasting all of our time and effort

  • Unknown's avatar

    let me close this post and move to the correct forum

    Sorry for wasting your time.

  • The topic ‘How to add the data from a checkbox as a meta key/pair’ is closed to new replies.