Looks good to me. Indenting will go leaps and bounds on readability:
PHP Code:
<?php
if (isset($_POST['username'], $_POST['password'], $_POST['repassword'], $_POST['email']))
{
$errors = array();
$username = $_POST['username'];
$password = $_POST['password'];
$repassword = $_POST['password'];
$email = $_POST['email'];
if (empty($username) || empty($password) || empty($repassword)|| empty($email))
{
$errors[] = 'All fields are required';
}
else
{
if (strlen($username) > 25 )
$errors[] = 'Username can not be longer than 12 characters';
if (strlen($username) < 3 )
$errors[] = 'Username must be 3 characters or more';
if (strlen($password) < 5 )
$errors[] = 'Password must be 5 characters or more';
if (filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE)
$errors[] = 'Please enter a valid email address';
}
if (!empty($errors))
{
foreach ($errors as $error)
{
echo $error;
}
}
else
{
echo 'woop';
}
}
?>
I'd also suggest to always use blocks for the conditional checks instead of next instruction implicit check. Its easy to make an error by adding an instruction and then not knowing why its always set. It is up to you on that one though.
The foreach can also be skipped and you can use an implode on the $errors instead to give it a separator.
Edit:
Wait, you may have one off here. The else for the 'woop' may or may not be any good, but there's no clear indication what that should be. That else block would indicate that everything is fine.
You may want to add another else to indicate that it didn't receive all the fields required.