Hy Guys,
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.
Thanks for taking a look.
<?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
{
?>
<?php
function reg_form()
{
echo "<table border='1'>
<form action='form_test.php' method='post'>
<tr><td>Desired ID:</td>
<td><input type='text' size='12' name='userid' /></td></tr>
<tr><td>Desired Password:</td>
<td><input type='password' size='12' name='userpassword' /></td></tr>
<tr><td><input type='hidden' name='submit' value='true' />
<input type='submit' value='Submit' />
<input type='reset' value='Reset' /></td></tr>
</form>
</table>";
}
reg_form();
?>
<?php
}
?>