kevinritt Posted August 23, 2011 Share Posted August 23, 2011 I would like to take info from a membership form that I created for my website and store it in a database. Can anyone recommend a tutorial that would guide me through the basics of doing this? The membership form has about 25 fields that I'd like to store in a db and referrence as needed. This is a wordpress site and i tried Gravity Forms but I need to have more flexibilty in the form creation. (I know this forum is for code already written, so admin can you move to apporpriate forum?) Thanks Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 23, 2011 Share Posted August 23, 2011 This is a good one. http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme for your ref: http://www.techtipsdigital.com/wordpress-contact-form-7-plugin-tutorial/337/ http://www.idiotproofblogging.com/wordpress/contact-form-7-wordpress-install-tutorial.html Quote Link to comment Share on other sites More sharing options...
kevinritt Posted August 23, 2011 Author Share Posted August 23, 2011 Thanks Voip03, That tutorial will get me started but my form is quite extensive: name, address, state, zip, phone, business, etc and will have input, radio, drop down fields. Creating the form is not a problem. The things I'm weak on are validation (best practices, security), inserting into database (I can do basic but I want to make sure I do it correctly) and I need a way to access the info once it's submitted. I'd need to send an email to admin whenever the form is submitted. Gravity Forms is great but it's the customization that's the problem. I know it's a lot - thanks for any help Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 24, 2011 Share Posted August 24, 2011 Never trust the user and always validate user input At the user end you can use JavaScript to validate the input, at the sever side PHP can be use. 1.Input fields are not empty if(!empty($_POST["FirstName"])) { not empty} 2. Email validation //Validate an E-mail Address function check_email_address($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } 3.PHP and Radio Buttons <?PHP $male_status = 'unchecked'; $female_status = 'unchecked'; if (isset($_POST['Submit1'])) { $selected_radio = $_POST['gender']; if ($selected_radio = = 'male') { $male_status = 'checked'; } else if ($selected_radio = = 'female') { $female_status = 'checked'; } } ?> The HTML FORM code: <FORM name ="form1" method ="post" action ="radioButton.php"> <Input type = 'Radio' Name ='gender' value= 'male' <?PHP print $male_status; ?> >Male <Input type = 'Radio' Name ='gender' value= 'female' <?PHP print $female_status; ?> >Female <P> <Input type = "Submit" Name = "Submit1" VALUE = "Select a Radio Button"> </FORM> Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 24, 2011 Share Posted August 24, 2011 Advanced PHP Form Input Validation http://www.devshed.com/c/a/PHP/Advanced-PHP-Form-Input-Validation-to-Check-User-Inputs/ Good Luck Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.