Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

problem to do the trick

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

problem to do the trick

Postby sendy » Sat Dec 22, 2012 7:19 am

example i have a form validation script which test if user has filled all of the fields.
i set up the $errors variable, and test each field if they have errors or not
Code: Select all
$required_fields = array('username' , 'password', 'email');
foreach($required_fields as $field)
        $errors[] = "Please fill {$_POST[$field]}";

then i want to:
Add code to the handling of the $errors variable on the page that uses a foreach loop if $errors is an array, or just prints the value of $errors otherwise.

what im thinking is using is_array() function, to test $errors :

Code: Select all
if( is_array($errors) )

then i tried to use var_dump() to test $errors (even if there is only 1 error) unfortunately its still an array.

i cant figure it out..
New php-forum User
New php-forum User
Posts: 9
Joined: Thu Oct 25, 2012 9:47 pm

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.