Re: php Form Validation help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



See below for point-by-point.

...
 
> 
> <CODE>
> 
> $state = $_POST['state'];
> 
> if ($state = 0) {

= is an assignment operator.  This will always test true, because $state
is set to 0 every time this is called.  You want ==, which is a
comparison operator.

>             print '<p>Please select your State</p>';
> 
>             }
> 
> </CODE>
> 

....

> <CODE>
> 
> $phone = $_POST['p-areacode'] . - . $_POST['p-prefix']. - .
> $_POST['p-suffix'];
> 
> </CODE>

More like:

$phone = $_[PST[area] . "-" ......

You get the idea -- dashes need to be surrounded by quotes.

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

You can check the string length and see if it's within the bounds you
want.  Look at the Strings section of the PHP manual for the proper
function (str_len, I think).

> 
> Would this be somewhat on the right track?
> 
> <CODE>
> 
> If ($zip str >5) {
> 
> print '<p>Please enter your Zip Code (EX. 77662)</p>';
> 
>             }
> 
> </CODE>

Nope.  If someone entered 98115, then this would be > 5, since there's a
difference of 98110 integers :)

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

See comment on string length above.

>  
> 
> I am still new with PHP, any help would be appreciated. Below is the code I
> have sofar:
> 
>  


Hope this helps.
-- 
Peter Ellis - pellis@xxxxxxxxxxxxxxx
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux