If you mean you're calling userdata() then trying to use the variables $name, $surname, $email, then no, you can't do that. The function has a scope that is separate from the scope of the script you're running. So the file that does the including of your function userdata, that has a scope that is all encompassing of that script in if() statements, switches, and other typical procedural style code. Functions, since they're their own block of procedural code, have their own scope outside of what the currently running script's is.
So the $name variable in your function is a separate variable that the $name in the root of the script. For example:
<?php
function userdata()
{
$name = 'Brett';
}
$name = 'Joe';
userdata();
echo $name; // prints "Joe"
?>
If you were to add the "global" keyword to the function, and declare that the $name variable be global, then you would be working with the variables that are in the entire script:
<?php
function userdata()
{
global $name;
$name = 'Brett';
}
$name = 'Joe';
userdata();
echo $name; // prints 'Brett'
?>
You can list as many variables as you need on the "global" line, just separate them by variables:
global $name, $surname, $email;
Hope that helps.