title: php registration form not working properly
body: <p>I am using Apache 2.4.3, MySQL 5.5.27, PHP 5.4.7, phpMyAdmin 3.5.2.2. Please help me I can't go further without knowing this. In my code below I have <code>$errors[]='All fields required';</code> and this won't work for me. It won't show any errors until I change it to <code>echo 'All fields required';</code>. But this code was taken from a video tutorial and it worked for him.
  Can anyone tell me the reason it's not working for me?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  include 'ini.php';
  ?&gt;
  
  &lt;form action="register.php" method="post"&gt;
     &lt;p&gt;Username:&lt;br/&gt;&lt;input type="text" name="reg_u_name" maxlength="20" &gt;&lt;/p&gt; 
     &lt;p&gt;Password:&lt;br/&gt;&lt;input type="password" name="reg_password" maxlength="20" &gt;&lt;/p&gt;
     &lt;p&gt;&lt;input type ="submit" value="Register" &gt;&lt;/p&gt;
  &lt;/form&gt;
  
  &lt;?php
  if (isset( $_POST['reg_u_name'], $_POST['reg_password'] )) {
     $reg_u_name = $_POST['reg_u_name'];
     $reg_password = $_POST['reg_password'];
  
     $errors = array();
  
     if (empty($reg_u_name) || empty($reg_password)) {
        $errors[] = 'All fields required';
     } else {
        if (strlen($reg_u_name) &gt; 50 || strlen($reg_password) &gt; 50) {
           $errors[] = 'One or more fields contains too many characters';
        }
     }
  }
  ?&gt;
  </code></pre>
  
  <p>If anyone giving negative votes pls tell the reason</p>