Recommended Posts

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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]

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...