Just to clarify:
"The user will put his name" is the "user will put his username" and not their propername (terminology is everything).
If it is username then you can do a look up on it, but this is complicated if you have multiple authentication methods:
$user = $DB->get_record('user', array('username' => $name));
This will work but you get strange effects if there are 2 accounts with the same username but different authmethods, so you should also include "auth". For instance the following will restrict it to users that use the manual auth method:
$user = $DB->get_record('user', array('username' => $name, 'auth' => 'manual));
The question is, is the user already logged in? Because if this is all happening within Moodle, you can pick up the current user's record via the $USER super variable, so you don't need to ask them for details...(just a thought).
Also please never do: $name=$_POST[user]; without validating the user input!
If your page is within moodle you should be doing either
$name = required_param('user', PARAM_ALPHA)
$name = optional_param('user', '', PARAM_ALPHA);
Hope this helps.