Solved

Making a custom form in WordPress

Posted on 2014-01-22
5
536 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
ID: 39801246
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
ID: 39801583
That's great, Jason.  Thanks a ton! ~Ray
0
 
LVL 108

Author Closing Comment

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

Expert Comment

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

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to create your own WordPress Theme Before I begin with the theme design tutorial, I would like to give you the basics of what is required to make a WordPress Theme. The most basic WordPress theme only requires 2 files: a style.css file and an…
In Part I (http://www.experts-exchange.com/Web_Development/Blogs/WordPress/A_8410-Getting-Started-In-WordPress-Part-I.html), I introduced you to the powerful WordPress backend, the WordPress administrative Dashboard.  In Part II, I will introduce yo…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

895 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

13 Experts available now in Live!

Get 1:1 Help Now