Copy link to clipboard
Copied
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.
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
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.