Well, use the method I described, but convert it into PHP and put it on top of your php page. And instead of a cookie, use the database.... It can't be simpler then that...
Get_Current_IP
if (Current_IP isin Database) {
Get_Name_Out_of_Database
} else {
Ask_Name
Store_Name_In_Database
Store_Current_IP_In_Database
}
print_name_with_some_welcome_msg
do_rest_of_page
yadda_yadda