I am going to give the most basic example of what I want to achieve.

I have a page for booking a pickup service, and a form needs to be created to take information of the following.

(Date, # of Bottles, Name, Address, phone #)

Once the data is entered I want the info to be stored in a database, where I can later export it back on a page. Where I will have a list of each entry containing that data.

How do I go about doing this in wordpress, I have done something similar in php a while ago, my memory is a little bit bad though. Is there some sort of process. I don't really know where to start.

(not needed just yet, but for the date, I want to delete a certain date, once it has been chosen before once, and I want to have a drop down menu to choose dates, specifically time increments of 30mins e.g. monday 19th 8:30, 9:00 instead of the user choosing their own time)

Thanks for any help.

3 Answers 3


I would created custom post type for this and store all information (Date, # of Bottles, Name, Address, phone #) in post meta.

It would be a lot easier, if you use Gravity Forms or Ninja Forms, personally I've not used last one, but it has free lite version so it's worth to try.

  • I am not that familiar with custom post types and post meta, actually not at all. Do you have a example that might help me along. Jan 25, 2012 at 1:57
  • Example of custom post types and post meta used in forms?
    – Mamaduka
    Jan 25, 2012 at 7:04
  • yes, as Mamaduka, is really hard for me to understand your answer, can u provide any sample? Jan 25, 2012 at 23:30

I don't see the reason why to go that complicated, you can easily use contact-form-7 with a database extension, that would store everything on a database that you can check, export to excel, plain text, etc, and also gives you the option to display all the results on a single page using shortcodes.

I'm leaving you the two links:

Once installed, just create the form you just described, and when some1 submits it, you just need to go to Contact -> Database.

And of course, it allows you to delete any register whenever you want.

Have fun!


Let's try a lightweight approach without plugins first. In your page template, e.g. page-pickup.php (with "pickup" being the page slug), you can just create your HTML form as you would do normally.

You can leave the action attribute on your <form> empty. That way the form will be submitted to the same page. Also, creating a hidden input with your form name will help to determine whether the form got submitted or not.

At the top of that same file, you check whether the form was submitted or not. Then you do the usual form data cleaning and validation and take the appropriate action afterwards: showing errors or saving/e-mailing the data.

Here's a bare-bones example:

if (isset($_POST['pickup-form']))
    // Clean POST data
    $demo_input = (isset($_POST['demo-input'])) ? trim((string) $_POST['demo-input']) : '';

    // Validate POST data
    if ('' === $demo_input)
        $errors['demo_input'] = __('Demo field is required');

    // No errors
    if (empty($errors))
        // Save POST data to database, send some e-mails, etc.
        $success = TRUE;

<?php if ( ! empty($success)) { ?>

    <p>Thank you!</p>

<?php } else { ?>

    <?php if ( ! empty($errors)) { ?>
        <?php print_r($errors) ?>
    <?php } ?>

    <form method="post" action="">
        <input type="hidden" name="pickup-form">
        <input type="text" name="demo-input" value="<?php if (isset($demo_input)) { echo esc_attr($demo_input); } ?>">
        <input type="submit">

<?php } ?>
  • So how do I go abouts saving this data/grabbing it later. Jan 25, 2012 at 1:13
  • My answer is focused on the form logic. You can use $wpdb to save and retrieve data from the database.
    – Geert
    Jan 25, 2012 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.