have a form that I would like to validate before it is submitted to the DB.
I am having trouble with a couple of sections.
I have a select box with a listing of all the states, the first option is
"Choose One" with a value of "0". Would this be the correct way to
"validate" this field?
<CODE>
$state = $_POST['state'];
if ($state = 0) {
print '<p>Please select your State</p>';
}
</CODE>
Second, another part of the same form I have fields for phone numbers, once
the field is submitted I would like to join the 3 sections of areacode, nxx
and prefix. I have done this to join them, is this correct?
<CODE>
$phone = $_POST['p-areacode'] . - . $_POST['p-prefix']. - .
$_POST['p-suffix'];
</CODE>
The next question id for both phone number and area code.
If I want to validate the zip code and ensure a minimum of X characters in
the field, numbers only how would I do this?
Would this be somewhat on the right track?
<CODE>
If ($zip str >5) {
print '<p>Please enter your Zip Code (EX. 77662)</p>';
}
</CODE>
And for the phone number I would assume I could use:
<CODE>
If ($_POST['p-areacode'] str >3 ) {
print '<p>Please enter your Area Code (EX. 77662)</p>';
}
</CODE>
I am still new with PHP, any help would be appreciated. Below is the code I
have sofar: