how to organize this code and add some validation
<p>I'm having a hard time trying to figure it out how to organize the following piece of code so i can add a few validations for a form:</p>

<pre><code>&lt;?php

//Calculo em php 
$valor_final = 1320 - 1.2 * $_POST['val1'];
$valor_confiscado = $_POST['val1'] - $valor_final;
$valor_total = $valor_confiscado + $valor_confiscado;

$valor_final1 = "&lt;div class=info&gt;&lt;span class=style1&gt;Parcela do subsidio de Férias/Natal que fica para o trabalhador ou aposentado:&lt;/span&gt; &lt;span class=style2&gt;$valor_final Euros&lt;/span&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;";
$valor_confiscado1 = "&lt;div class=error&gt;&lt;span class=style1&gt;Parcela do subsidio de Férias/Natal que o governo confisca:&lt;/span&gt; &lt;span class=style2&gt;$valor_confiscado Euros&lt;/span&gt;&lt;/div&gt;";
$valor_total1 = "&lt;div class=error&gt;&lt;span class=style1&gt;Parcela dos 2 subsidios juntos (Natal e Férias) confiscado pelo governo:&lt;/span&gt; &lt;span class=style2&gt;$valor_total Euros&lt;/span&gt;&lt;/div&gt;";

//Resultados
if($_SERVER['REQUEST_METHOD'] == "POST") 
{
    echo $valor_final1;
    echo $valor_confiscado1;
    echo $valor_total1;
}
?&gt;
</code></pre>

<p>Before I echo the 3 variables I would like to check if the value inserted on the textbox <code>$_POST['val1']</code> is less than 600 and greater than 1100, if so i would like to echo other msg instead of the $valor_final etc...
As you can see I have a if statment that checks if the page is getting hit by post form, so it can hide the message if nothing has been submited by the user, I would like to keep it or a better solution for this.</p>

<p>This is the best example for what i need: </p>

<pre><code>if (($_SERVER['REQUEST_METHOD'] == "POST") || ($_POST['val1'] &lt; 600)) 
{ echo $toolow;}
if (($_SERVER['REQUEST_METHOD'] == "POST") || $_POST['val1'] &gt; 1100)) 
{ echo $toohigh;}
elseif (($_SERVER['REQUEST_METHOD'] == "POST")
    echo $valor_final1;
    echo $valor_confiscado1;
    echo $valor_total1;
}
</code></pre>

<p>Im trying to do this by my own since 2 days ago, but i got tired :S</p>

<p>Edit: </p>

<p>I did this: </p>

<pre><code>&lt;?php
$valor_final = 1320 - 1.2 * $_POST['val1'];
$valor_confiscado = $_POST['val1'] - $valor_final;
$valor_total = $valor_confiscado + $valor_confiscado;
if ($_POST['val1'] &lt;= 600);{
echo "&lt;div class=error&gt;&lt;span class=style1&gt;O governo não pretende confiscar subsidios inferiores a 600 euros:&lt;/span&gt;&lt;/div&gt;";
exit; 
}
if ($_POST['val1'] &gt;= 1100);{
echo "&lt;div class=error&gt;&lt;span class=style1&gt;O governo não pretende confiscar subsidios inferiores a 1100 euros:&lt;/span&gt;&lt;/div&gt;";
exit; 
}
else {
echo "&lt;div class=info&gt;&lt;span class=style1&gt;Parcela do subsidio de Férias/Natal que fica para o trabalhador ou aposentado:&lt;/span&gt; &lt;span class=style2&gt;$valor_final Euros&lt;/span&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;";
echo "&lt;div class=error&gt;&lt;span class=style1&gt;Parcela do subsidio de Férias/Natal que o governo confisca:&lt;/span&gt; &lt;span class=style2&gt;$valor_confiscado Euros&lt;/span&gt;&lt;/div&gt;";
echo "&lt;div class=error&gt;&lt;span class=style1&gt;Parcela dos 2 subsidios juntos (Natal e Férias) confiscado pelo governo:&lt;/span&gt; &lt;span class=style2&gt;$valor_total Euros&lt;/span&gt;&lt;/div&gt;";
}

?&gt;
</code></pre>

<p>And it trowns me this error:
Parse error: syntax error, unexpected T_ELSE in /home/terrachat/domains/terrachat.com.pt/public_html/projectos/calcular_work.php on line 139</p>

<pre><code>**Line 137 exit; 
Line 138 }
Line 139 else {
Line 140 echo "&lt;div class=info&gt;&lt;span class=style1&gt;Parcela do subsidio de Férias/Natal que fica para o trabalhador ou aposentado:&lt;/span&gt; &lt;span class=style2&gt;$valor_final Euros&lt;/span&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;";**
</code></pre>

<p>Can someone please help with this?</p>

<p>Sincerely</p>
