Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Mandatory drop down menus

New Here ,
May 04, 2009 May 04, 2009

Dear all,

1. I want to create a form that will generate details that will be sent to my hosted SQL database that has as its first question where do you live, it will be a drop down menu. I need to have the visitor fill this part out first. Is it easy to make sure that a term on the drop down is selected before the visitor to the site can move on? i.e. they are told if they hit continue to fill in the missing term.

2. I have done something similar (having details filled out by a visitor in an online form) using a php script to send an email with the details to my email address, however, this time I want the details to go straight into my SQL database table. How feasible is this?

Kind regards,

T.

TOPICS
Server side applications
501
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 04, 2009 May 04, 2009

The normal way to handle this type of thing is with server-side validation. In PHP, it would be something like this:

if ($_POST) {

  $error = array();

  if (empty($_POST['location'])) {

    $error[] = 'You must specify a location';

  }

  // other validation tests

  if (!$error) {

    // insert the data into the database

  }

}

This series of conditional statements prevents the data from being inserted into the database unless it meets your validation criteria. If it fails, you simply redisplay the page with

...
Translate
LEGEND ,
May 04, 2009 May 04, 2009

The normal way to handle this type of thing is with server-side validation. In PHP, it would be something like this:

if ($_POST) {

  $error = array();

  if (empty($_POST['location'])) {

    $error[] = 'You must specify a location';

  }

  // other validation tests

  if (!$error) {

    // insert the data into the database

  }

}

This series of conditional statements prevents the data from being inserted into the database unless it meets your validation criteria. If it fails, you simply redisplay the page with the error messages.

Unfortunately, Dreamweaver doesn't do the validation scripting for you automatically, but it's not too difficult.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2009 May 05, 2009
LATEST

Dear David,

Thanks again, that one doesn't actually look too hard to understand; I'm going to give it a whirl!

Many thanks for taking the time to answer.

Kind regards,

T.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines