isset() not working properly on form
<p>I have a registration form that user submits, data is sent using isset($_POST) to see if there is anything that was put into form input boxes.  If not it is sent to an else which then sends it to a function that returns the user back to registration form to complete some missing forms. For some reason it is not working properly.</p>

<p>Here is my checking code -------</p>

<pre><code>function returnBack(){

    header("Location:register.php");
    exit;

}

if(isset($_POST['myusername']))
{
    $myusername = $_POST['myusername'];
}
else
{
    returnBack();   
}
if(isset($_POST['mypassword']))  {
    $mypassword=$_POST['mypassword'];

}
else{   

    returnBack();
}
if(isset($_POST['myemail']))  {

    $myemail=$_POST['myemail'];
}
else{

    returnBack();
}
if(isset($_POST['myname']))  {

    $myname=$_POST['myname'];
}
else{

    returnBack();
}
if(isset($_POST['mylastname'])){

    $mylastname=$_POST['mylastname'];

}
else{

    returnBack();
}
/////////////////////////////////////////////////////////////*******CONNECT TO SERVER ******************************************************************/
try {  
  # MySQL with PDO_MYSQL  
  $DBH = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);  
  $DBH-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

}  
catch(PDOException $e) { 
    echo "I'm sorry, I'm afraid I can't do that.";  
    file_put_contents('PDOErrors.txt', $e-&gt;getMessage(), FILE_APPEND);   
}
////////////////////////////////////////////////////////////***********INSERT REGISTER DATA INTO DB ***************************************************************/
//$encrypt_password = md5($mypassword);

$insertdata = $DBH-&gt;prepare("INSERT INTO members (username, password, email, firstname, lastname ) VALUES ('$myusername','$mypassword','$myemail','$myname','$mylastname')");
$insertdata-&gt;execute();
echo "success";

$DBH = null; 
</code></pre>

<p>Here is the form section ------------------------------</p>

<pre><code>&lt;table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"&gt;
&lt;tr&gt;
&lt;form name="register" method="post" action="insertnewmem.php"&gt;
&lt;td&gt;
&lt;table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"&gt;
&lt;tr&gt;
&lt;td colspan="3"&gt;&lt;strong&gt;Registration Form &lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width="78"&gt;Username&lt;/td&gt;
&lt;td width="6"&gt;:&lt;/td&gt;
&lt;td width="294"&gt;&lt;input name="myusername" type="text" id="myusername" &gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password&lt;/td&gt;
&lt;td&gt;:&lt;/td&gt;
&lt;td&gt;&lt;input name="mypassword" type="text" id="mypassword"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Email&lt;/td&gt;
&lt;td&gt;:&lt;/td&gt;
&lt;td&gt;&lt;input name="myemail" type="text" id="myemail"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First Name&lt;/td&gt;
&lt;td&gt;:&lt;/td&gt;
&lt;td&gt;&lt;input name="myname" type="text" id="myname"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Last Name&lt;/td&gt;
&lt;td&gt;:&lt;/td&gt;
&lt;td&gt;&lt;input name="mylastname" type="text" id="mylastname"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;input type="submit" name="Submit" value="Register"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/form&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>UPDATED ----------------------------------------------</p>

<p>Sorry it skips the function returnBack() and just inserts it into db even if form not properly filled.</p>
