Best method for custom login/register
drupal_get_form('user_login');


And 

drupal_get_form('user_register_form');


Will return the form for you and will deal with all the form stuff that needs to be dealt with. You just need to print whatever is returned by that function out and it should work.

Note: You did not specify the Drupal version, when using 7, drupal_get_form() returns an array which you need to pass through drupal_render() first to get a string that you can print.