It destroys the thread if you keep editing the original post, all the fixes no longer make any sense to some one visiting it in the future.
the last problem:
this:
$sql='INSERT INTO $tbl (id,firstname,username,password,email)VALUES(id(),'$firstname','$username','$password','$email')';
should be
$sql="INSERT INTO $tbl (id,firstname,username,password,email)VALUES(id(),'$firstname','$username','$password','$email')";