I am new to php validation. I'm working on registration form, which will go through php script for database checking two unqiue variables ac_title and email then after checking errors. It will insert the given values in databases. The file name is formvu.php then it'll move to activate.php. I'm getting the problem that if I use 
<form name="fone" method="post" onsubmit="return validateform(fone)" action="activate.php">
form will ignore the php script and it will move to next page. Buh when I'll use this:
<form name="fone" method="post" onsubmit="return validateform(fone)" action="<?php $_SERVER['PHP_SELF']?> ">
now page it will run whole the php errors and commands.
Here is my whole php code:
<?php
    if($_SERVER["REQUEST_METHOD"] == "POST")
    {
        $nun=$_POST['account'];
        $em=$_POST['email'];
        $register="SELECT ac_title,email FROM register";
        $query=mysql_query($register);
        while ($row= mysql_fetch_array($query))
        {   
            if ($nun == $row['ac_title'])
            {
                print "<span class=\"phclass\"><br/><b>
                    Your Account Title :</b></span>"." '"."<span class=\"ahclass\"><b>$nun</b></span>"."'".
                    " <span class=\"phclass\"><b>already exsist, please choose different.</b></span><br/>";
            }
            if($em == $row['email'])
            {
                print "<span class=\"phclass\"><b><br/>Your Email:</b>
                    </span>"." "."<span class=\"phclass\"><b> $em</b></span>"."<span class=\"phclass\">
                    <b> already exsist, please visit <a href=\"resetpassword.html\">
                    Forget password</a></b></span><br/>";
            }
            if ($nun != $row['ac_title'] && $em != $row['email'])
            {
                $ac_title=$_POST['account'];
                $email=$_POST['email'];
                $pass=$_POST['pwd'];
                $fn=$_POST['fname'];
                $gd=$_POST['gender'];
                $city=$_POST['city'];
                $VID=$_POST['vuid'];
                $course=$_POST['courseid'];
                $camp=$_POST['campus'];
                $hash=md5(rand(0,1000));
                $sql="INSERT INTO register (ac_title, email, pass,fn, sex, city,
                    VID, CRS, campus, hash,activate) VALUES('$ac_title', '$email',
                    '$pass','$fn', '$gd',' $city','$VID','$course',
                    '$camp','$hash','0')";
                $inst=mysql_query($sql,$connection);
                if (!$inst)
                {   
                    print "";
                }
                else 
                {
                    echo "Succesful ";
                }
            }// if
        } // while
    } // if
?>
If the action is default page it will run whole script. I want to run whole script and move to Next page (activate.php).
 
     
     
     
     
    