DokGonzo Posted March 14, 2010 Report Posted March 14, 2010 I have a simple contact form I'm using for potential clients to send me their information. I'm using a simple PHP script to email the form contents, which works fine. However, what I want to do is make it so that if a disclaimer checkbox is not checked, then the email will not send, and the user will see an error message. I don't want a dialog box or anything. What I have right now is red text that describes the error, but its default display style is set to hidden in my CSS sheet. What I'd like is for it to become visible if the checkbox is not checked, so that the user knows why the contact failed. Additionally, I have 3 areas of the form that are marked "required." I'd also like something similar to happen if any one of them is not filled in. Like if the "Name" box has not been edited, then red text appears that says something like, "You must enter your name." or something. Obviously I'm an extreme novice, so any help is much appreciated. Thanks. Quote
SRP Posted March 14, 2010 Report Posted March 14, 2010 Hello, Are you using any kind of cms? Because if you are then this can be very easy. Quote
DokGonzo Posted March 14, 2010 Author Report Posted March 14, 2010 I'm actually not even sure what CMS is. My pages are pretty straightforward HTML, with a single external CSS file governing all of them. Quote
SRP Posted March 14, 2010 Report Posted March 14, 2010 Then you probably aren't using a cms. CMS stands for Content Management System. Such like Joomla and Drupal. Wordpress is sometimes also seens as a CMS but it's a blogsystem. Quote
DokGonzo Posted March 14, 2010 Author Report Posted March 14, 2010 In that case, then no, I'm not using a CMS. I think maybe the way I'm thinking about this won't work... using the PHP script to "edit" the HTML in the page? Like I said, I don't want a dialog box. I want formerly hidden text to display next to the checkbox. Quote
DokGonzo Posted March 14, 2010 Author Report Posted March 14, 2010 I think I understand that the initial part of the PHP script would go like this: if(!isset($_POST['Checkbox'])) { do stuff }[/PHP] The problem is, I don't know how to make it "do stuff" like I want it to. Quote
tfk11 Posted March 16, 2010 Report Posted March 16, 2010 Basically what you want is a page that goes something like this: // set form default $values if( !emtpy($_POST) ) { // update the forms $values with posted values // validate the $values and collect any error messages } // show page header if( !empty($validation_messages) ) { // show the validation messages } // show the form using the $values // show page footer [/PHP] Quote
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.
Note: Your post will require moderator approval before it will be visible.