At 11:09 07/09/2004 +0000, you wrote:
From: "Vincent Jordan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Mon, 6 Sep 2004 19:20:16 -0400
MIME-Version: 1.0
Content-Type: multipart/alternative;
        boundary="----=_NextPart_000_0004_01C49446.8C688C60"
Subject: php Form Validation help

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?

if ($_POST["state"]==0) { // Display error message that no state is selected print '<p>Please select your State</p>'; }

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?

Almost there : Put quotes around parts of your output that aren't variables (ie quote literal text strings)


$phone = $_POST['p-areacode'] . "-" . $_POST['p-prefix']. "-" .$_POST['p-suffix'];

>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?

if (strlen($zip_str) < 5) { print '<p>Please enter your Zip Code (EX. 77662)</p>'; }

HTH
Cheers - Neil



-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to