title: Fatal error: Call to undefined function reg_form() in C:\xampp\htdocs\php\BEGINNING PHP 5\mysql\form_test.php on line 18
body: <p>Hy Guys,</p>
  
  <p>I'm new to PHP, The PHP book I am referring it says - "Functions can be called before the actual function definition appears in code.". In the following code, I am calling _reg_form();_ before the function is defined below but I am the getting the error. What am I doing wrong.</p>
  
  <p>Thanks for taking a look.</p>
  
  <pre><code>&lt;?php
  include('common_db.inc');
  include('validation.php');
  
  if(!$link=db_connect()) die(sql_error());
  if($_POST['submit'])
  {
    $userid = $_POST['userid'];
    $userpassword=$_POST['userpassword'];
    $username=$_POST['username'];
    $userposition = $_POST['userposition'];
    $useremail=$_POST['useremail'];
    $userprofile=$_POST['userprofile'];
    $result=validate();
    if($result==0)
    {
     reg_form();
    }
   else 
   {
     mysql_query("INSERT INTO user VALUES(NULL,'$userid',Password('$userpassword'),'$username','$userposition','$useremail','$userprofile')",$link);
   }
  }
  else
  {
  ?&gt;
  &lt;?php
  function reg_form()
  {
   echo "&lt;table border='1'&gt;
   &lt;form action='form_test.php' method='post'&gt;
    &lt;tr&gt;&lt;td&gt;Desired ID:&lt;/td&gt;
    &lt;td&gt;&lt;input type='text' size='12' name='userid' /&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Desired Password:&lt;/td&gt;
    &lt;td&gt;&lt;input type='password' size='12' name='userpassword' /&gt;&lt;/td&gt;&lt;/tr&gt; 
    &lt;tr&gt;&lt;td&gt;&lt;input type='hidden' name='submit' value='true' /&gt;
    &lt;input type='submit' value='Submit' /&gt;
    &lt;input type='reset' value='Reset' /&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;/form&gt;
  &lt;/table&gt;";
  }
  
    reg_form();
   ?&gt;
  &lt;?php
  }
  ?&gt; 
  </code></pre>