 <p>try this:</p> <pre><code> $name = $_POST['name']; $email = $_POST['email']; $custom_field1 = $_POST['custom_field1']; $custom_field2 = $_POST['custom_field2']; $error = array(); if($name=='') { $error[] = 'Name are mandatory'; } if($email == '') { $error[] = 'Email are mandatory'; } if($custom_field1 == '') { $error[] = 'Custom field 1 is mandatory'; } if($custom_field2 == '') { $error[] = 'Custom field 2 is mandatory'; } if (!empty($error)) { $custom_field3 = $_POST['custom_field3']; $boolean = 'true'; $postdata = http_build_query( array( 'name' =&gt; $name, 'email' =&gt; $email, 'custom_field1' =&gt; $custom_field1, 'custom_field2' =&gt; $custom_field2, 'custom_field3' =&gt; $custom_field3, 'list' =&gt; $list, 'boolean' =&gt; 'true' ) ); $opts = array('http' =&gt; array('method' =&gt; 'POST', 'header' =&gt; 'Content-type: application/x-www-form-urlencoded', 'content' =&gt; $postdata)); $context = stream_context_create($opts); $result = file_get_contents($app_url.'/signin', false, $context); if ($result != 1) $error[] = $result; } } </code></pre> <p>When you displaying the error messages, make a loop in <code>$error</code> array</p> <pre><code>foreach ($error as $errstr) { echo "&lt;p&gt;{$errstr}&lt;/p&gt;"; } </code></pre> <p>or <code>implode</code> to string and echoes like</p> <pre><code>echo "&lt;p&gt;" . implode("&lt;/p&gt;&lt;p&gt;", $error) . "&lt;/p&gt;"; </code></pre>