Register Module with PHP validation
<p>I have a registration module with PHP validation.</p>

<p>This coding shows the error and how to check the username availability using MySQL.
I gave HTML file PHP validation File.</p>

<p>This is my runtime error:
<code>syntax error, unexpected $end in F:\xampp\htdocs\mycode\exec.php on line 60</code></p>

<p>Thanks in advance.</p>

<p><strong><code>exec.php</code></strong></p>

<p>

<pre><code>$todo = $_POST['todo'];
if ($todo == "submit-form")
{
    $status_form = "OK";
    $msg = "";

    $uname = $_POST['uname'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $pass = $_POST['pass'];
    $pass1 = $_POST['cpass'];
    $sex = $_POST['gender'];
    $dob = $_POST['dob'];
    $city = $_POST['city'];
    $mob = $_POST['mob'];

    if ($uname = '' || $name = '' || $email = '' || $pass = '' || $pass1 = '' || $sex = '' || $dob = '' || $city = '' || $mob = '')
    {
        $status_form = "NOTOK";
        $msg .= "fields r empty&lt;br&gt;";
    }
    if (strlen($uname) &lt; 5)
    {
        $status_form = "NOTOK";
        $msg .= "Your Name must be more than 5 char  length&lt;br&gt;";
    }
    if (isset($todo) and $todo == "submit-form")
    {
        if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
        {
            $status_form = "NOTOK";
            $msg .= "invalid Email&lt;br&gt;";
        }
        if (strcmp($pass, $pass1) != 0)
        {
            $status_form = "NOTOK";
            $msg .= "password do not match&lt;br&gt;";
        }
        if (strlen($sex) &lt; 1)
        {
            $status_form = "NOTOK";
            $msg .= "Please select Sex&lt;br&gt;";
        }
        if (is_numeric($mob))
        {
            $status_form = "NOTOK";
            $msg .= "Please enter numeric&lt;br&gt;";
        }
        if ($status_form == "OK")
        {
            // do your data insertion as validation is passed
            $msg = "Thanks &lt;br&gt; Your data validation is passed ";
            header("Location: thank.php?msg=$msg");
        }
        else
        {

            while (list ($key, $val) = each($_POST))
            //echo $pd;
                header("Location: reg2.php?msg=$msg&amp;$pd");
        }// end of else if status_form is not ok
    }// checking of todo value
} // was missing
</code></pre>

<p><strong><code>reg2.php</code></strong></p>

<pre><code>&lt;div &lt;?php $msg = $_GET['msg'];
    echo "&lt;font color=red&gt;$msg&lt;/font&gt;"; ?&gt; &lt;/div&gt;
&lt;form method="post" action="exec.php"&gt;
    &lt;input type="hidden" name="todo" value="submit-form" /&gt;
    &lt;table width="475" height="167" border="0"&gt;
        &lt;tr&gt;
            &lt;td height="23"&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td width="159" height="23"&gt;Username&lt;/td&gt;
            &lt;td width="10"&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td width="170"&gt;
                &lt;input type="text" name="uname" value="&lt;?php echo '$uname'; ?&gt;" /&gt;       &lt;/td&gt;
            &lt;td width="118"&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td height="23"&gt;Name&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="name" value="&lt;?php echo '$name'; ?&gt;" /&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td height="23"&gt;Email&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="email" value="&lt;?php echo '$email'; ?&gt;"/&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Password&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="pass" value="&lt;?php echo '$pass'; ?&gt;" /&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;confirm password &lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="cpass" value="&lt;?php echo '$cpass'; ?&gt;" /&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Gender&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;input type="radio" name="gender" value="male" /&gt;Male&lt;input type="radio"  name="gender" value="female" /&gt;Female&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Date of Birth &lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="dob" value="&lt;?php echo '$dob'; ?&gt;"/&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;City&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="city" value="&lt;?php echo '$city'; ?&gt;"/&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Mobile No &lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;input name="mob" type="text" maxlength="10" value="&lt;?php echo '$mob'; ?&gt;"/&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Profile Photo &lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&lt;input type="file" name="file" /&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&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;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&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="submit"/&gt;&lt;/td&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/form&gt;
</code></pre>
