Solved

Making a custom form in WordPress

Posted on 2014-01-22
5
532 Views
Last Modified: 2014-01-23
Can someone please post links to learning resources that can tell me how to do the following tasks in WordPress:

1. Present an HTML form to gather a client's name and email address
2. Run the Action= script  that receives the input from the form
3. Add the name and email address to a custom data base table.

I'm an experienced PHP developer but I don't know WordPress at all and have just begun creating a child theme and a plugin.  So I'm looking for a little jump-start on some of the basic tasks.

Thanks and regards, ~Ray
0
Comment
Question by:Ray Paseur
  • 3
  • 2
5 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
Comment Utility
Hi Ray,

There are LOTS of ways to skin this particular cat.  The exact method you choose will largely be determined by how tightly integrated you want the data to be.  A simple collection form without further extraction on the front end is a relatively simple thing for any developer and requires a minimal knowledge of WordPress trivia.  The solutions get progressively more complicated from there...

The easiest and least WordPressy way to do this is to make a custom page template:

http://codex.wordpress.org/Page_Templates

in the theme and just add all the relevant PHP and HTML to the template and only minimally worry about the WordPress architecture and ecosystem.  

On the WordPress side, when you go to publish the page with the form, you use the Template Selector shown in the link above to choose this template.  Content is optional...you are hardcoding it anyway so all content could be in the template file or you could position the_content() above or below your hardcoded form and the page template will display the content as needed.

-----------------

The next step up in complexity is to "do it the WordPress way" and use WordPress functions to register the new table within the hierarchy which makes it visible and available to other WordPress functions. The best and most basic explanation I have found is this one:

http://wp.tutsplus.com/sessions/custom-database-tables/

It's a little below your level but it does a nice job of showing the WordPress-specific syntax used to pass MySQL queries to registered tables with $wpdb.

-------------

The most WordPress-specific way of doing this is to not use a table at all and instead register everything as custom fields.  There is a fair bit of controversy about the wisdom of this, especially on large sites so I will just mention it and leave it alone otherwise.

You can also use plugins to bypass the developer entirely, but again I sense that's not quite what you are looking to do.
0
 
LVL 108

Author Comment

by:Ray Paseur
Comment Utility
That's great, Jason.  Thanks a ton! ~Ray
0
 
LVL 108

Author Closing Comment

by:Ray Paseur
Comment Utility
Just what I was looking for, thanks!
0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
You're welcome.  Feel free to post back here with anything you need clarification on.
0
 
LVL 108

Author Comment

by:Ray Paseur
Comment Utility
Yeah, I know Andrew.  He's a member of the DC PHP Users Group.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now